Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Load config settings from yaml and environment variables.
Ruby
Tag: v0.0.4

0.0.4

latest commit 1cfda1f484
@spraints authored
Failed to load latest commit information.
lib 0.0.4
spec Support IP addresses in env vars.
.gitignore Generated a gem.
.rspec
.travis.yml A license is good.
Gemfile Replace autotest with guard.
Guardfile Use temp files for yaml file specs.
MIT-LICENSE A license is good.
README.md Add build status.
Rakefile Add default task for travis.
static_config.gemspec Fill out gemspec.

README.md

Example

MyAppConfig = StaticConfig.build do
  first do
    env_yaml 'my_app_config'
    file Rails.root.join('config/my_app.yml'), :section => Rails.env
  end
  env 'MY_APP'
end

Now you have an object MyAppConfig that you can use anywhere.

For instance, if your config/my_app.yml looks like this:

development:
  user:
    selected:
      color: orange

You could get orange by doing this:

MyAppConfig.user.selected.color

You could override it at runtime by setting the environment variable MY_APP_USER_SELECTED_COLOR.

You can also override the entire config/my_app.yml file by storing some yaml in an environment variable called my_app_config.

To get your config to reload on each request in Rails, add this:

Rails.application.config.to_prepare do
  MyAppConfig.reload!
end

Build Status

Something went wrong with that request. Please try again.