Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds an environment_vars_fallback to the Settingslogic class #63

Closed

Conversation

@leonelgalan
Copy link

@leonelgalan leonelgalan commented Nov 11, 2013

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 2 commits Nov 11, 2013
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.
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
Copy link

@m5rk m5rk commented Nov 19, 2013

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

Loading

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

2 participants