colin (owner)

Fork Of

gist: 230531 by jnunemaker simple app configuration

Revisions

gist: 230974 Download_button fork
public
Public Clone URL: git://gist.github.com/230974.git
Embed All Files: show embed
harmony.rb #
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
module Harmony
  # Allows accessing config variables from harmony.yml like so:
  # Harmony[:domain] => harmonyapp.com
  def self.[](key)
    unless @config
      raw_config = File.read(RAILS_ROOT + "/config/harmony.yml")
      @config = YAML.load(raw_config)[RAILS_ENV].symbolize_keys
    end
    @config[key]
  end
  
  def self.[]=(key, value)
    @config[key.to_sym] = value
  end
end
 
harmony.yml #
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
DEFAULTS: &DEFAULTS
  email: no-reply@harmonyapp.com
  email_signature: |
    Regards,
    The Harmony Team
 
development:
  domain: harmonyapp.local
  <<: *DEFAULTS
  
test:
  domain: harmonyapp.com
  <<: *DEFAULTS
 
production:
  domain: harmonyapp.com
  <<: *DEFAULTS