Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

App configuration feat. YAML and JVM properties

branch: master

Fetching latest commit…

Octocat-spinner-32-eaf2f5

Cannot retrieve the latest commit at this time

Octocat-spinner-32 lib
Octocat-spinner-32 spec
Octocat-spinner-32 .gitignore
Octocat-spinner-32 .rspec
Octocat-spinner-32 .travis.yml
Octocat-spinner-32 CHANGELOG.md
Octocat-spinner-32 Gemfile
Octocat-spinner-32 LICENSE
Octocat-spinner-32 README.md
Octocat-spinner-32 Rakefile
Octocat-spinner-32 ambience.gemspec
README.md

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.

Something went wrong with that request. Please try again.