Skip to content
master
Go to file
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
lib
 
 
 
 
 
 
 
 
 
 
 
 
 
 

README.markdown

configutron

configutron is a rails gem for simple, application wide settings. there are tons of projects like this; each does it differently, and this is how i like to do it. all the ones I tried seemed too heavy handed. i am publishing this as a convenience for myself to use in projects i work on.

tested on rails 2.3.5, 2.3.8, and 3.0.0.rc

usage

in non-bundler rails projects:

Rails::Initializer.run do |config|
  config.gem 'configutron'
end

in your Gemfile

gem 'configutron'

you have two options for specifying settings.

  1. one file (config/settings.yml)
  2. one file per environment (config/settings/environment_name.yml)

option 1 takes precedence; that is, if config/settings.yml exists, it will be used, and the config/settings directory will be ignored.

config/settings.yml

this option uses one file for the application, with settings for each environment nested under the environment's name, like database.yml.

add your variables to that file:

% echo "--- \ndevelopment: \n  variable: value\n" > config/settings.yml

try it out:

% ./script/console 
Loading development environment (Rails 2.3.5)
$ >> Configutron.variable
% => "value

config/settings/RAILS_ENV.yml

create a folder config/settings. configutron will be available for each environment that has a corresponding yaml file in that directory.

% mkdir config/settings

add your variables to those files:

% echo "--- \nvariable: value\n" > config/settings/development.yml

try it out:

% ./script/console
Loading development environment (Rails 2.3.5)
>> Configutron.variable
=> "value"

name it something easier to type:

config/initializers/configutron.rb

Configutron.constant = 'App'

try it out:

% ./script/console
Loading development environment (Rails 2.3.5)
>> App.variable
=> "value"

also

  • erb works

inspiration

thanks

note on patches/pull requests

  • fork the project.
  • make your feature addition or bug fix.
  • add tests for it. this is important so i don't break it in a future version unintentionally.
  • commit, do not mess with rakefile, version, or history. (if you want to have your own version, that is fine but bump version in a commit by itself i can ignore when i pull)
  • send me a pull request. bonus points for topic branches.

copyright

copyright (c) 2010 neal clark. See LICENSE for details (MIT License).

About

simple app-wide settings for rails apps (yet another AppConfig)

Resources

License

Packages

No packages published

Languages

You can’t perform that action at this time.