No commit activity in last 3 years
No release in over 3 years
Reads YAML files with configuration. Allows you to specify default configuration file you can store in repository and overwrite it with custom configuration file for each application instance and environment.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
 Project Readme

AmberBit Config

¶ ↑

Provides simple global configuration for ruby applications using YAML files.

Installation:

¶ ↑

With bundler:


1. Edit Gemfile, located in your application and add the following line:
    gem 'amberbit-config'
2. Run bundle:
    bundle install
3. Use rake to generate configuration files:
    rake amberbit:config:setup
4. Make sure that ./config/app_config.yml stays in .gitignore

As a rails engine:


It will work without any other actions as a rails engine. It takes environment name from:

ENV['RAILS_ENV'] or ENV['RACK_ENV'] or ENV['APP_CONFIG_ENV']

AppConfig should be initialized before environment configuration. If you need to use it within ./config/application.rb then add after Bundler.require

require 'amberbit-config'
AmberbitConfig.initialize_within File.dirname(__FILE__)

Any ruby application


For any other app require and initialize AppConfig as above, just make sure that there's an ENV variable. You can also specify files to load, i.e.:

require 'amberbit-config'
ENV['RACK_ENV'] = 'development'
AmberbitConfig.initialize 'config/app_config_default.yml', 'config/app_config.yml'

Tested with Ruby on Rails, Sinatra, and plain old ruby.

Usage:

¶ ↑

Place your application configuration default values into ./config/app_config_default.yml:

default:
  application:
    name: SuperApp
    url: http://localhost:3000/

test:
  # overwrite application.url key only in test env
  application:
    url: http://testhost:3000/

And overwrite values you wish on per-installation basis in ./config/app_config.yml:

default:
  application:
    name: SuperApp specially for you

production:
  application:
    url: http://yoursuperhiperdomain.com

In your application Ruby code you can access the values in 2 following ways:

AppConfig["application"]["name"] #=> SuperApp specially for you

or

AppConfig.application.name #=> SuperApp specially for you

Keys are deep-merged, for example:

production env:

AppConfig.application.name #=> SuperApp specially for you
AppConfig.application.url #=> http://yoursuperhiperdomain.com

development env:

AppConfig.application.name #=> SuperApp specially for you
AppConfig.application.url #=> http://localhost:3000/

Copyright © 2008/2011 Wojciech Piekutowski, Hubert Łępicki, Piotr Tynecki released under the MIT license