lib/sdbport/config.rb in sdbport-0.2.1 vs lib/sdbport/config.rb in sdbport-0.3.0

- old
+ new

@@ -1,20 +1,34 @@ module Sdbport class Config - attr_reader :access_key, :secret_key - def initialize @config = load_config_file - @access_key = @config.fetch 'access_key', nil - @secret_key = @config.fetch 'secret_key', nil end + def access_key(account) + if @config.has_key? account + @config[account].fetch 'access_key', nil + else + nil + end + end + + def secret_key(account) + if @config.has_key? account + @config[account].fetch 'secret_key', nil + else + nil + end + end + + private + def load_config_file config_file = "#{ENV['HOME']}/.sdbport.yml" if File.exists? config_file - YAML::load File.open(config_file) + YAML::load(File.open(config_file)) else Hash.new end end