module Google::Cloud

def self.auto_load_files

Other tags:
    Private: -
def self.auto_load_files
  if Gem.respond_to? :find_latest_files
    return Gem.find_latest_files "google-cloud-*.rb"
  end
  # Ruby 2.0 does not have Gem.find_latest_files
  Gem.find_files "google-cloud-*.rb"
end

def self.auto_load_gems

Other tags:
    Private: -
def self.auto_load_gems
  currently_loaded_files = loaded_files
  auto_load_files.each do |auto_load_file|
    auto_load_file = File.realpath auto_load_file
    next if currently_loaded_files.include? auto_load_file
    require auto_load_file
  end
end

def self.configure

Returns:
  • (Google::Cloud::Config) - The top-level configuration object for
def self.configure
  @config ||= Config.create
  yield @config if block_given?
  @config
end

def self.init_configuration

Other tags:
    Private: -
def self.init_configuration
  configure do |config|
    default_project = Google::Cloud::Config.deferred do
      ENV["GOOGLE_CLOUD_PROJECT"] || ENV["GCLOUD_PROJECT"]
    end
    default_creds = Google::Cloud::Config.deferred do
      Google::Cloud::Config.credentials_from_env \
        "GOOGLE_CLOUD_CREDENTIALS", "GOOGLE_CLOUD_CREDENTIALS_JSON",
        "GOOGLE_CLOUD_KEYFILE", "GOOGLE_CLOUD_KEYFILE_JSON",
        "GCLOUD_KEYFILE", "GCLOUD_KEYFILE_JSON"
    end
    config.add_field! :project_id, default_project,
                      match: String, allow_nil: true
    config.add_alias! :project, :project_id
    config.add_field! :credentials, default_creds, match: Object
    config.add_alias! :keyfile, :credentials
    config.add_field! :on_error, nil, match: Proc
  end
end

def self.loaded_files

Other tags:
    Private: -
def self.loaded_files
  files = Array(caller).map do |backtrace_line|
    until backtrace_line.split(":").size < 2 || File.file?(backtrace_line)
      backtrace_line = backtrace_line.split(":")[0..-2].join ":"
    end
    backtrace_line
  end
  files.uniq!
  files.select! { |file| File.file? file }
  files.map { |file| File.realpath file }
end

def self.new project_id = nil, credentials = nil, retries: nil, timeout: nil

Returns:
  • (Google::Cloud) -

Parameters:
  • timeout (Integer) -- Default timeout to use in requests. Optional.
  • retries (Integer) -- Number of times to retry requests on server
  • credentials (String, Hash, Google::Auth::Credentials) -- The path to
  • project_id (String) -- Project identifier for the service you are
def self.new project_id = nil, credentials = nil, retries: nil, timeout: nil
  gcloud = Object.new
  gcloud.instance_variable_set :@project, project_id
  gcloud.instance_variable_set :@keyfile, credentials
  gcloud.instance_variable_set :@retries, retries
  gcloud.instance_variable_set :@timeout, timeout
  gcloud.extend Google::Cloud
  gcloud
end

def self.warn_nonrecommended_ruby cur_version, recommended_version

Other tags:
    Private: -
def self.warn_nonrecommended_ruby cur_version, recommended_version
  warn "WARNING: You are running Ruby #{cur_version}, which is nearing" \
    " end-of-life."
  warn "The Google Cloud API clients work best on supported versions of" \
    " Ruby. Consider upgrading to Ruby #{recommended_version} or later."
  warn "See https://www.ruby-lang.org/en/downloads/branches/ for more" \
    " info on the Ruby maintenance schedule."
  warn "To suppress this message, set the" \
    " GOOGLE_CLOUD_SUPPRESS_RUBY_WARNINGS environment variable."
end

def self.warn_on_old_ruby_version \

Other tags:
    Private: -
def self.warn_on_old_ruby_version \
    supported_version: SUPPORTED_VERSION_THRESHOLD,
    recommended_version: RECOMMENDED_VERSION_THRESHOLD
  return if ENV["GOOGLE_CLOUD_SUPPRESS_RUBY_WARNINGS"]
  cur_version = Gem::Version.new RUBY_VERSION
  if cur_version < Gem::Version.new(supported_version)
    warn_unsupported_ruby cur_version, recommended_version
  elsif cur_version < Gem::Version.new(recommended_version)
    warn_nonrecommended_ruby cur_version, recommended_version
  end
rescue ArgumentError
  warn "Unable to determine current Ruby version."
end

def self.warn_unsupported_ruby cur_version, recommended_version

Other tags:
    Private: -
def self.warn_unsupported_ruby cur_version, recommended_version
  warn "WARNING: You are running Ruby #{cur_version}, which has reached" \
    " end-of-life and is no longer supported by Ruby Core."
  warn "The Google Cloud API clients work best on supported versions of" \
    " Ruby. It is strongly recommended that you upgrade to Ruby" \
    " #{recommended_version} or later."
  warn "See https://www.ruby-lang.org/en/downloads/branches/ for more" \
    " info on the Ruby maintenance schedule."
  warn "To suppress this message, set the" \
    " GOOGLE_CLOUD_SUPPRESS_RUBY_WARNINGS environment variable."
end