Adds an environment_vars_fallback to the Settingslogic class #63

Closed
wants to merge 2 commits into
from

Conversation

Projects
None yet
2 participants

I wrote this to play nicer with Heroku or Travis-ci, where it's easier to set environment variables.

If set to true, non existing settings attempt to retrieve value from
environment variables. For example:

class Settings < Settingslogic
   source "#{File.dirname(__FILE__)}/settings.yml"
   suppress_errors true
   environment_vars_fallback true
 end

ENV['SETTINGS_NON_EXISTENT_KEY']='foo'
Settings.non_existent_key.should == 'foo'

leonelgalan added some commits Nov 11, 2013

Stores an array of @sections instead of a single string in @section
Before `Setting.a.b.c` had `@section == "'b' section in 'a' section in
'[PATH]/settings.yml'"`, now it has `@sections == ['b', 'a',
'Settting']`. The purpose of this commit, is to have the section's
"stack" available and not just a string.

The only use of `@section` was to show a meaningful MissingSetting
message, this is not change in this commit and the message is so
similar, all tests are passing.
Adds an environment_vars_fallback to the Settingslogic class
If set to true, non existing settings attempt to retrieve value from
environment variables. For example:

`Settings.non_existent_key == 'foo' ` if
`ENV['SETTINGS_NON_EXISTENT_KEY']='foo'` and Settings has
`environment_vars_fallback true`

m5rk commented Nov 19, 2013

@leonelgalan You may be interested in chamber, which supports overriding from the environment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment