Sha256: 32b6bfd498a92c4e136b3d47774263c25270da02305fec3461ebacf601830786
Contents?: true
Size: 1.25 KB
Versions: 3
Compression:
Stored size: 1.25 KB
Contents
module Heirloom class Config attr_accessor :access_key, :secret_key, :metadata_region, :logger, :environment, :use_iam_profile def initialize(args={}) @opts = args[:opts] ||= Hash.new @logger = args[:logger] ||= HeirloomLogger.new @environment = args[:environment] ||= 'default' @config = load_config_file load_config end def load_config @access_key = @opts.fetch :aws_access_key, @config['access_key'] @secret_key = @opts.fetch :aws_secret_key, @config['secret_key'] @metadata_region = @opts.fetch :metadata_region, @config['metadata_region'] @use_iam_profile = @opts.fetch :use_iam_profile, false end private def load_config_file config_file = "#{ENV['HOME']}/.heirloom.yml" if File.exists? config_file data = YAML::load File.open(config_file) if data.has_key? @environment data[@environment] else @logger.error "Environment '#{@environment}' not found in config file." exit 1 end else { } end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
heirloom-0.11.2 | lib/heirloom/config.rb |
heirloom-0.11.1 | lib/heirloom/config.rb |
heirloom-0.11.0 | lib/heirloom/config.rb |