Sha256: 15ecf80a59b2b362c3deba15e3f8937ca4a673f375357cedc38e43477a18cd19

Contents?: true

Size: 710 Bytes

Versions: 2

Compression:

Stored size: 710 Bytes

Contents

module Heirloom
  class Config

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

    def initialize(args = {})
      @config = args[:config] ? args[: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.0rc2 lib/heirloom/config.rb
heirloom-0.5.0rc1 lib/heirloom/config.rb