module Fog
Format related hackery allows both true.is_a?(Fog::Boolean
) and false.is_a?(Fog::Boolean
) allows both nil.is_a?(Fog::Nullable::String
) and ''.is_a?(Fog::Nullable::String
)
Attributes
Public Class Methods
This is the named credential from amongst the configuration file being used or :default
@note This can be set using the FOG_CREDENTIAL
environment variable
@return [Symbol] The credential to use in Fog
# File lib/fog/core/credentials.rb, line 40 def self.credential @credential ||= (ENV["FOG_CREDENTIAL"] && ENV["FOG_CREDENTIAL"].to_sym) || :default end
Assign a new credential to use from configuration file
@param [String, Symbol] new_credential name of new credential to use @return [Symbol] name of the new credential
# File lib/fog/core/credentials.rb, line 30 def self.credential=(new_credential) @credentials = nil @credential = new_credential && new_credential.to_sym end
@return [Hash] The credentials pulled from the configuration file @raise [LoadError] Configuration unavailable in configuration file
# File lib/fog/core/credentials.rb, line 67 def self.credentials @credentials ||= begin if credentials_path && File.exist?(credentials_path) credentials = Fog::Core::Utils.prepare_service_settings(YAML.load_file(credentials_path)) (credentials && credentials[credential]) || Fog::Errors.missing_credentials else {} end end end
This returns the path to the configuration file being used globally to look for sets of credentials
@note This can be set using the FOG_RC
environment variable or defaults to +$HOME/.fog+
@return [String] The path for configuration_file
# File lib/fog/core/credentials.rb, line 50 def self.credentials_path @credential_path ||= begin path = ENV["FOG_RC"] || (ENV["HOME"] && File.directory?(ENV["HOME"]) && "~/.fog") File.expand_path(path) if path rescue nil end end
@return [String] The new path for credentials file
# File lib/fog/core/credentials.rb, line 60 def self.credentials_path=(new_credentials_path) @credentials = nil @credential_path = new_credentials_path end
# File lib/fog/core/wait_for_defaults.rb, line 8 def self.interval=(interval) if interval.is_a?(Proc) raise ArgumentError, "interval proc must return a positive" unless interval.call(1) >= 0 else raise ArgumentError, "interval must be non-negative" unless interval >= 0 end @interval = interval end
# File lib/fog/core/wait_for_defaults.rb, line 34 def self.max_interval=(interval) raise ArgumentError, "interval must be non-negative" unless interval >= 0 @max_interval = interval end
# File lib/fog/core/mock.rb, line 4 def self.mock! @mocking = true end
# File lib/fog/core/provider.rb, line 6 def self.providers @providers ||= {} end
# File lib/fog/core/service.rb, line 4 def self.services @services ||= {} end
@deprecated Don't use! @param [Object] key @return [true] if key == :headers
# File lib/fog/core/credentials.rb, line 81 def self.symbolize_credential?(key) ![:headers].include?(key) end
@deprecated Use {Fog::Core::Utils.prepare_service_settings} instead
# File lib/fog/core/credentials.rb, line 86 def self.symbolize_credentials(hash) Fog::Core::Utils.prepare_service_settings(hash) end
# File lib/fog/core/wait_for_defaults.rb, line 23 def self.timeout=(timeout) raise ArgumentError, "timeout must be non-negative" unless timeout >= 0 @timeout = timeout end
# File lib/fog/core/mock.rb, line 8 def self.unmock! @mocking = false end
# File lib/fog/core/wait_for.rb, line 2 def self.wait_for(timeout = Fog.timeout, interval = Fog.interval, &_block) duration = 0 start = Time.now retries = 0 loop do break if yield if duration > timeout raise Errors::TimeoutError, "The specified wait_for timeout (#{timeout} seconds) was exceeded" end sleep(interval.respond_to?(:call) ? interval.call(retries += 1).to_f : interval.to_f) duration = Time.now - start end { :duration => duration } end