A simple configuration tool for your ruby application settings
Ruby
Permalink
Failed to load latest commit information.
lib
spec Remove simplecov, it doesn't like ruby 1.8 Aug 4, 2014
.gitignore
.rspec Add rspec Jul 5, 2013
.ruby-version Fix the specs when running under travis-ci Jul 12, 2013
.travis.yml Add ruby 1.8.7 tests Mar 12, 2014
Gemfile Initial commit Jul 5, 2013
LICENSE.txt Initial commit Jul 5, 2013
README.md
Rakefile Make rspec the default rake task Jul 5, 2013
armoire.gemspec Remove simplecov, it doesn't like ruby 1.8 Aug 4, 2014

README.md

Armoire Build Status Code Climate

A simple configuration tool for your ruby application settings

Installation

Add this line to your application's Gemfile:

gem 'armoire'

And then execute:

$ bundle

Or install it yourself as:

$ gem install armoire

Usage

Armoire should be simple. Simply create a yaml file in config/application.yml with the following:

development:
  foo: "bar"
  baz: 42
  nested_options:
    nested_foo: "nested_bar"
    nested_baz: 99.999
  boolean_value: true
  parsed_things: <% "something_in_erb" %>

test:
  foo: "bar"
  baz: 42
  nested_options:
    nested_foo: "nested bar"
    nested_baz: 99.999
  boolean_value: true
  parsed_things: <% "something_in_erb" %>

Simply call Armoire["foo"] to get "bar" or Armoire["nested_options"]["nested_foo"] to get "nested_bar". Any ERB will be parsed when the config file is loaded. If a configuration option is missing, it will throw an Armoire::ConfigSettingMissing exception.

You may also call keys with any object that responds to #to_s and armoire will work correctly, e.g. Armoire[:foo].

The configuration environment will initially be taken from ENV['RAILS_ENV'], then ENV['RACK_ENV'] and if neither exist then it will fall back to development. Environment can also be set explicitly, but must be set prior to calling load!

Armoire.environment = 'not_rack'

Usage in Rails

This gem has a Railtie that automatically loads Armoire as early as it can in the load process, this means that Armoire will be available everywhere in your Rails application.

Usage in other frameworks

You need to tell Armoire to load your settings as early in the initialisation process as possible by doing:

Armoire.load! File.expand_path('config/application.yml', File.dirname(__FILE__))

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request