Configuration managment system with i18n like syntax
require "erb"
require "yaml"
def load_yml(yml_path)
YAML.load(ERB.new(File.read(yml_path)).result(binding))
end
app:
name: some app name
version: <%= File.read('VERSION') %>
subnamespace:
another_key: value
$cfg = Confrider.from_hash(load_yml('/path/to/settings.yml'))
# or short form
$cfg = Confrider(load_yml('/path/to/settings.yml'))
$cfg['app.name'] # => 'some app name'
$cfg['app.version'] # will be rendered through ERB
$cfg['app.subnamespace'] # => {'another_key' => 'value'}
$cfg['app.subnamespace.another_key'] # => 'value'
$cfg['non.existent.key'] # => nil
$cfg['non.existent.key', 'default'] # => 'default'
# load additional hash that will be deeply merged
$cfg.from_hash(load_yml('/path/to/settings_local.yml'))
Add this line to your application's Gemfile:
gem 'confrider'
And then execute:
$ bundle
Or install it yourself as:
$ gem install confrider
git checkout -b my-new-feature
)git commit -am 'Added some feature'
)git push origin my-new-feature
)