Class: AMEE::Config

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

Class Method Summary collapse

Class Method Details

.setup(amee_config_file = nil, environment = 'test') ⇒ Object

Tries to load defaults from a yaml file, then if there are environment variables present (i.e. if we’re using a service like heroku for determine them, or we want to manually override them), uses those values instead



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/amee/config.rb', line 12

def self.setup(amee_config_file = nil, environment = 'test')

  if amee_config_file
    # first try loading the yaml file
    yaml_config = YAML.load_file(amee_config_file)
    config = yaml_config[environment]

    # make config[:username] possible instead of just config['username']
    config.recursive_symbolize_keys!
  else
    config = {}
  end

    # then either override, or load in config deets from heroku
  config[:username] = ENV['AMEE_USERNAME'] if ENV['AMEE_USERNAME']
  config[:server]   = ENV['AMEE_SERVER'] if ENV['AMEE_SERVER']
  config[:password] = ENV['AMEE_PASSWORD'] if ENV['AMEE_PASSWORD']

  return config

end