A library that makes environment dependent configuration easy in Rails.
Ruby JavaScript
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
lib
pkg
spec
.gitignore
Gemfile
LICENSE
README.md
Rakefile
VERSION
environment_configurable.gemspec

README.md

environment_configurable

Description

A library that makes environment dependent configuration easy in rails.

Rationale

Environment dependent configuration is a common problem in rails, and we noticed a common pattern:

  • We tend to extract configuration variables to a yaml file
  • We often wrap the yaml configuration in a configuration helper

Environment Configurable accomplishes both of these task succinctly.

Install

  • gem install environment_configurable
  • Add config.gem "environment_configurable" to your environment.rb file

Dependencies

  • Rails 2.3.0 >=

Example

class S3Helper
  include EnvironmentConfigurable
  configure_with "config/s3.yml"
  
  def self.connect!
     AWS::S3::Base.establish_connection!(
        :access_key_id     => config.access_key_id,
        :secret_access_key => config.secret_access_key
      )
  end
end

s3.yml

production: &DEFAULTS
  access_key_id: ACCESS_KEY_ID
  secret_access_key: SECRET_ACCESS_KEY
  bucket: the-prod-bucket

staging:
  <<: *DEFAULTS
  bucket: the-staging-bucket

development:
  <<: *DEFAULTS
  bucket: the-development-bucket

test:
  <<: *DEFAULTS
  bucket: the-test-bucket

Authors