config_volumizer
Description
Ever wanted to move to ENV based 12 Factor config but are stuck with somewhat complex yaml (or simillar) files holding all your settings?
Been scratching your head how to convert your deeply nested config to ENV?
Config Volumizer comes to the rescue.
Examples
Convert this:
some:
setting:
- one
- two
- three
with:
another: setting
info a series of ENV variables like so:
some.setting[0] = one
some.setting[1] = two
some.setting[2] = three
some.with.another = setting
... and then just give it some volume with the volumizer to turn it back to the original rich structure
ConfigVolumizer.parse(ENV, 'some')
Features
Parsing
You can parse a flattened config via ConfigVolumizer.parse(ENV, 'some')
For example if your ENV was:
some.setting[0] = one
some.setting[1] = two
some.setting[2] = three
some.with.another = setting
This would yield a Hash like the following:
some:
setting:
- one
- two
- three
with:
another: setting
Generation
You can generate a flat list of configs (mostly as examples for your actual config) via:
ConfigVolumizer.generate(data_hash)
For example, given a hash simillar to:
some:
setting:
- one
- two
- three
with:
another: setting
You would get back a hash looking like this:
"some.setting[0]": one
"some.setting[1]": two
"some.setting[2]": three
"some.with.another": setting
Install
Add it to your gemfile and use it.
gem 'config_volumizer'
Copyright
Copyright (c) 2015 PayrollHero Pte. Ltd.
See LICENSE.txt for details.