Sha256: e2793c9db4b869388738d742075c79bb170b7b8ab3c77a23be8f0abbd99195a8

Contents?: true

Size: 698 Bytes

Versions: 2

Compression:

Stored size: 698 Bytes

Contents

module Heirloom
  class Config

    attr_accessor :access_key, :secret_key, :primary_region, :logger

    def initialize(args = {})
      @config = args.fetch :config, load_config_file
      self.logger = args[:logger] ||= HeirloomLogger.new
      load_config
    end

    def load_config
      aws = @config['aws']
      self.access_key = aws['access_key']
      self.secret_key = aws['secret_key']
      self.primary_region = aws['primary_region'] ||= 'us-west-1'
    end

    def load_config_file
      config_file = "#{ENV['HOME']}/.heirloom.yml"

      if File.exists? config_file
        YAML::load File.open(config_file)
      else
        { 'aws' => Hash.new }
      end
    end

  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
heirloom-0.5.0rc4 lib/heirloom/config.rb
heirloom-0.5.0rc3 lib/heirloom/config.rb