Module: Collins::Authenticator
- Defined in:
- lib/collins_auth.rb
Class Method Summary collapse
Class Method Details
.load_config(options = {}) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/collins_auth.rb', line 16 def self.load_config( = {}) conf = ([:prompt] == :only) ? {} : (read_config([:config_file]) || {}).merge() # check if we have all that we expect if [:username, :password, :host].all? {|key| conf.keys.include? key} return conf end # Something is missing. Can we prompt for it? if [:prompt] conf.merge!(prompt_creds(conf)) else raise "could not load any valid configuration." end conf end |
.setup_client(options = {:prompt => false}) ⇒ Object
8 9 10 11 12 13 14 |
# File 'lib/collins_auth.rb', line 8 def self.setup_client( = {:prompt => false}) if [:config_file] and not File.readable? [:config_file] raise 'unable to read invalid config file: ' + [:config_file] end Collins::Client.new load_config() end |