class Flo::Config
Instantiates and stores providers for use in command definitions
@attr_reader providers [Hash] Hash of provider instances
Attributes
cred_store[W]
providers[R]
Public Class Methods
new()
click to toggle source
# File lib/flo/config.rb, line 32 def initialize @providers = {} end
Public Instance Methods
cred_store()
click to toggle source
# File lib/flo/config.rb, line 48 def cred_store @cred_store ||= Flo::CredStore::YamlStore.new end
creds()
click to toggle source
Returns an object that responds to [], but instead of returning a value, returns a lambda that can be evaluated later in the context of the credentials for the provider @return [LazyCred]
# File lib/flo/config.rb, line 55 def creds LazyCreds.new end
provider(provider_sym, options={}, &blk)
click to toggle source
Instantiate a provider and add it to the {#providers} collection @param provider_sym [Symbol] @param options [Hash] Options to be passed to provider initialization @yield Yields the block to the provider initializer, in case the provider accepts a block
# File lib/flo/config.rb, line 42 def provider(provider_sym, options={}, &blk) provider = provider_class(provider_sym).new(options, &blk) provider.cred_store = cred_store.credentials_for(provider_sym) @providers[provider_sym] = provider end
Private Instance Methods
camel_case(str)
click to toggle source
# File lib/flo/config.rb, line 69 def camel_case(str) return str if str !~ /_/ && str =~ /[A-Z]+.*/ str.split('_').map{|e| e.capitalize}.join end
provider_class(provider_sym)
click to toggle source
# File lib/flo/config.rb, line 61 def provider_class(provider_sym) klass = camel_case(provider_sym.to_s) klass_name = "Flo::Provider::#{klass}" Object.const_get(klass_name) rescue NameError raise MissingRequireError.new("#{klass_name} is not loaded. Please require the library before use") end