Class: ResqueToCloudwatch::Config

Inherits:
Object
  • Object
show all
Defined in:
lib/resque_to_cloudwatch/config.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path) ⇒ Config

Returns a new instance of Config.



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/resque_to_cloudwatch/config.rb', line 10

def initialize(path)
  $log.info "Loading configuration"
  raise "Config file #{path} not found or readable" unless File.exists?(path)
  @required_opts = %w{access_key_id secret_access_key project period region redis_host redis_port hostname}
  @hash = YAML.load_file(path)
  raise "Config file #{path} is empty" unless @hash
  validate_config
  @required_opts.each do |opt|
    instance_variable_set("@#{opt}", @hash[opt])
    $log.info "Config parameter: #{opt} is #{@hash[opt]}"
  end
  
  # Set up AWS credentials
  AWS.config(
    :access_key_id => @hash['access_key_id'],
    :secret_access_key => @hash['secret_access_key'],
    :region => @hash['region']
  )
end

Instance Attribute Details

#access_key_idObject (readonly)

Returns the value of attribute access_key_id.



7
8
9
# File 'lib/resque_to_cloudwatch/config.rb', line 7

def access_key_id
  @access_key_id
end

#hostnameObject (readonly)

Returns the value of attribute hostname.



8
9
10
# File 'lib/resque_to_cloudwatch/config.rb', line 8

def hostname
  @hostname
end

#periodObject (readonly)

Returns the value of attribute period.



7
8
9
# File 'lib/resque_to_cloudwatch/config.rb', line 7

def period
  @period
end

#projectObject (readonly)

Returns the value of attribute project.



7
8
9
# File 'lib/resque_to_cloudwatch/config.rb', line 7

def project
  @project
end

#redis_hostObject (readonly)

Returns the value of attribute redis_host.



8
9
10
# File 'lib/resque_to_cloudwatch/config.rb', line 8

def redis_host
  @redis_host
end

#redis_portObject (readonly)

Returns the value of attribute redis_port.



8
9
10
# File 'lib/resque_to_cloudwatch/config.rb', line 8

def redis_port
  @redis_port
end

#regionObject (readonly)

Returns the value of attribute region.



7
8
9
# File 'lib/resque_to_cloudwatch/config.rb', line 7

def region
  @region
end

#secret_access_keyObject (readonly)

Returns the value of attribute secret_access_key.



7
8
9
# File 'lib/resque_to_cloudwatch/config.rb', line 7

def secret_access_key
  @secret_access_key
end