0.0
No commit activity in last 3 years
No release in over 3 years
simple app-wide settings for rails applications
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

>= 0.2.1
>= 1.2.9

Runtime

 Project Readme

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).