ActiveConfig is a fork/rewrite of CnuConfig, a yaml based config management system written in ruby. They philosphy for it is simple: More things can change in your code than just RAILS_ENV. Configuration parsing shouldn’t be difficult. It should be something you use liberally. Making a value configurable should be almost as easy as hardcoding a value.

Historically, the way CnuConfig (and thus ActiveConfig) have been used is as a constant. Create a constant for your app, for example MyConfig=ActiveConfig.new(:path => File.join(RAILS_ROOT,”etc”))

ActiveConfig then reads all the Yaml files out of the etc directory of your Rails app, and makes them available in MyConfig as indifferent hashes. For example, assuming you have a file called “mail.yml” containing

return-address: foo@bar.com
  work: 60606
  home: 60605

Now you can access that via MyConfig.return-address, and MyConfig.zip.work. Also, since MyConfig.zip is a hash, you can use all the normal hash methods on it.

This is convenient, but this doesn’t demonstrate the power of ActiveConfig. ActiveConfig allows you to define a set of “overrides” for configuration data. For example:

mail: mail.fixmetodo.com
db: malice.fixmetodo.com


db: greed.fixmetodo.com

When ActiveConfig finds you are running in the “production” rails mode, it will load all the data from servers.yml, then it will overlay the data from servers_production.yml.
MyConfig.mail will always return mail.fixmetodo.com
MyConfig.db will return malice.fixmetodo.com UNLESS you are running in production. Then it will use greed.fixmetodo.com

ActiveConfig does a few other things, and is quite configurable, but I figured I at least wanted to start describing it here. It is a power tool, and is hosted at github http://github.com/jlawler/activeconfig

Styles and HTML partially stolen fromWordPress
(as it's running fixmetodo.com, my blog)