Configutron is a project mainly written in Ruby, based on the MIT license.
simple app-wide settings for rails apps (yet another AppConfig)
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
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.
option 1 takes precedence; that is, if config/settings.yml exists, it will be used, and the config/settings directory will be ignored.
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 "---
development:
variable: value
" > config/settings.yml
try it out:
% ./script/console
Loading development environment (Rails 2.3.5)
$ >> Configutron.variable
% => "value
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 "---
variable: value
" > config/settings/development.yml
try it out:
% ./script/console
Loading development environment (Rails 2.3.5)
>> Configutron.variable
=> "value"
config/initializers/configutron.rb
Configutron.constant = 'App'
try it out:
% ./script/console
Loading development environment (Rails 2.3.5)
>> App.variable
=> "value"
copyright (c) 2010 neal clark. See LICENSE for details (MIT License).