Rails and Rack applications configuration made easy.
gem install easy_config
or in your Gemfile
gem "easy_config"
Inside config dir, create a file redis.yml:
development:
host: 127.0.0.1
port: 6379
password:
production:
host: 172.0.0.1
port: 6379
password: "alpha"
In your ruby code, you do:
Redis.current = Redis.new({
host: EasyConfig.redis.host,
port: EasyConfig.redis.port,
password: EasyConfig.redis.password
})
You can provide additional custom config paths.
Config file at vendor/config/sample.yml
:
development:
property: "value"
Code:
EasyConfig.append_config_path Rails.root.join('vendor/config')
puts EasyConfig.sample.property
Output will be: "value"
# ENV['APP_API_KEY'] = '1234567890'
puts EasyConfig.app.api_key
EasyConfig allows you to access your config files easily. All you have to do is to put your files in config dir and be a valid YAML file (with .yml as extension).
If you desire you can split your configurations by environment. Easy config treats it automatically.
- 2.1
- 2.0
- 1.9.3
- ree (will be dropped after 1.0)
Copyright (c) 2012-2014 Felipe Oliveira <http://felipecvo.github.io/>