This repository is private.
All pages are served over SSL and all pushing and pulling is done over SSH.
No one may fork, clone, or view it unless they are added as a member.
Every repository with this icon (
) is private.
Every repository with this icon (
This repository is public.
Anyone may fork, clone, or view it.
Every repository with this icon (
) is public.
Every repository with this icon (
| name | age | message | |
|---|---|---|---|
| |
CHANGELOG | Wed Jul 01 15:42:31 -0700 2009 | |
| |
README.rdoc | Wed Jul 01 15:42:31 -0700 2009 | |
| |
Rakefile | Wed Jul 01 15:42:31 -0700 2009 | |
| |
VERSION.yml | Wed Jul 01 15:42:31 -0700 2009 | |
| |
app_config.gemspec | Wed Jul 01 15:42:31 -0700 2009 | |
| |
init.rb | Wed Jul 01 15:42:31 -0700 2009 | |
| |
install.rb | Mon May 19 10:21:21 -0700 2008 | |
| |
lib/ | Wed Jul 01 15:42:31 -0700 2009 | |
| |
tasks/ | Mon May 19 10:21:21 -0700 2008 | |
| |
test/ | Wed Jul 01 15:42:31 -0700 2009 | |
| |
uninstall.rb | Mon May 19 10:21:21 -0700 2008 |
Summary
Application level configuration.
Features
* simple YAML config files * config files support ERB * config files support inheritance * access config information via convenient object member notation
Basic Usage
You simply write a configuration file in YAML. Notice you can use ERB.
config.yml
aws:
access_key: 123ABC
secret_key: ABC123
now: <%= Time.now %>
servers: [ {name: example1.com}, {name: example2.com} ]
Then somewhere in your code, you create a global constant from the config file. Then access the config data via object member notation.
code
::AppConfig = ApplicationConfiguration.new("config.yml")
AppConfig.aws.access_key # => "123ABC"
AppConfig.aws.secret_key # => "ABC123"
AppConfig.now # => Tue May 05 21:55:15 -0500 2009
AppConfig.servers[0].name # => "example1.com"
Inheritance
You can have a second config file that is recursively merged with the first config file.
base.yml
app_name: MyCoolApp domain: dev.mycoolapp.com
production.yml
domain: www.mycoolapp.com
code
::AppConfig = ApplicationConfiguration.new("base.yml", "production.yml")
AppConfig.app_name # => "MyCoolApp"
AppConfig.domain # => "www.mycoolapp.com"
Using in a Rails app
You just need to create an initializer that looks something like this.
require 'app_config'
::AppConfig = ApplicationConfiguration.new(RAILS_ROOT+"/config/app_config.yml",
RAILS_ROOT+"/config/environments/#{RAILS_ENV}.yml")
If you installed this as a Rails plugin instead of a gem, that code is already run for you in the plugin’s init.rb.
Author
Christopher J. Bottaro











