Project

ambience

0.0
No commit activity in last 3 years
No release in over 3 years
App configuration feat. YAML and JVM properties
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 0.9.12
= 0.8.7
~> 2.6.0

Runtime

>= 0.2.0
 Project Readme

Ambience Build Status

App configuration feat. YAML and JVM properties. Lets you specify a default configuration in a YAML
file and overwrite details via local settings and JVM properties for production.

Installation

Ambience is available through Rubygems and can be installed via:

$ gem install ambience

Getting started

Ambience expects your configuration to live inside a YAML file:

auth:
  address: http://example.com
  username: ferris
  password: test

You can create a new Ambience config by passing in the path to your config file:

AppConfig = Ambience.create Rails.root.join("config", "ambience.yml")

Ambience loads your config and converts it into a Hash:

{ "auth" => { "address" => "http://example.com", "username" => "ferris", "password" => "test" } }

Afterwards it tries to merge these settings with app-specific setting stored in a file which path is provided through the AMBIENCE_CONFIG environment variable. Also, if you're using JRuby, Ambience will merge all JVM properties with the config Hash:

auth.address = "http://live.example.com"
auth.password = "topsecret"

The result would be something like this:

{ "auth" => { "address" => "http://live.example.com", "username" => "ferris", "password" => "topsecret" } }

You can get the final config as a Hash:

AppConfig = Ambience.create(Rails.root.join("config", "ambience.yml")).to_hash

or a Hashie::Mash:

AppConfig = Ambience.create(Rails.root.join("config", "ambience.yml")).to_mash

Railtie

Ambience comes with a Railtie which looks for config/ambience.yml inside your Rails project.
If the file exists, Ambience loads the config and stores it in an AppConfig constant.
All this happens before Rails evaluates your environment config.