h1. ConfigatronPlus
An addition to Configatron to make it easy to read configuration from default settings and multiple locations including environmental variables.
h2. Configatron
Find out more at “Configatron”:github.com/markbates/configatron
h2. Installation
Installation of ConfigatronPlus
is easy, as it is just a RubyGem:
TODO: finish wrapping things up as gem
<pre><code>
$ sudo gem install configatron-plus
</code></pre>
Once installed you just need to require it:
<pre><code>
require 'configatron-plus'
</code></pre>
h2. Usage
ConfigatronPlus
stores all of its own configuration inside configatron. Use the following to see the current setup:
<pre><code>
puts configatron.to_hash #dump it as a straight ruby code. puts configatron.inspect #show the code you'd need to recreate the current config
</code></pre>
h2. Config
There are 5 parameters that can be configured, all of which have defaults. All 5 are located at <pre><code>
configatron.configatron_plus </code></pre>
|_. Parameter |_. Use |_. Default | | env_prefix | change this to change the prefix used in to look for values in the ENV | configatron_ | | fail_when_missing | change this to true to raise an error when a file in sources is not found on the filesystem | false | | rc_name | the default name of the file to look for | config.rb | | source_files | the actual file name used for a given symbol | <pre>:current => #{configatron.configatron_plus.rc_name}</pre> | | sources | The list of files and symbols to load | <pre>[:current, :env]</pre> |
h3. default
The default config looks like this when inspect
<pre><code>
configatron.configatron_plus.env_prefix = "configatron_" configatron.configatron_plus.fail_when_missing = false configatron.configatron_plus.rc_name = "config.rb" configatron.configatron_plus.source_files = {:current=>"config.rb"} configatron.configatron_plus.sources = [:current, :env]
</code></pre>
h2. Examples
h3. Default
By default, ConfigurationPlus looks for a config.rb file in the current directory, and reads any Environmental Variables with a name that starts with configatron_
<pre><code>
ConfigatronPlus.fetch_sources #Checks the current dir for config.rb and reads from environmental variables
</code></pre>
h3. Different default filename and prefix
To look for an alternate filename, set the rc_name parameter
<pre><code>
configatron.configatron_plus.rc_name = "my_app.rb" configatron.configatron_plus.env_prefix = "my_app_ ConfigatronPlus.fetch_sources #Checks the current dir for my_app.rb and reads from environmental variables starting with my_app_
</code></pre>
h2. Contact