¶ ↑
SettingslogicSettingslogic is an old library of mine that I decided to go ahead and share with the world. It’s nothing crazy or new. Just a simple solution to a simple problem. Settingslogic provides globally accessible settings via an ERB enabled YAML file. It has been great for my apps, maybe you will enjoy it too.
So here is my question to you.….is Settingslogic a great settings solution or the greatest?
¶ ↑
Helpful links* Documentation: settingslogic.rubyforge.org
-
Bugs / feature suggestions: binarylogic.lighthouseapp.com/projects/19028-settingslogic
¶ ↑
Install and usesudo gem install settingslogic
For rails, as a gem (recommended):
# config/environment.rb config.gem "settingslogic"
Or as a plugin (for older versions of rails)
script/plugin install git://github.com/binarylogic/settingslogic.git
¶ ↑
Create your settingsBy default Settingslogic tries to load config/application.yml. This is just a typical YAML file, notice ERB is allowed.
# app/config/application.yml defaults: &defaults cool: saweet: nested settings neat_setting: 24 awesome_setting: <%= "Did you know 5 + 5 = " + (5 + 5) + "?" %> development: <<: *defaults neat_setting: 800 test: <<: *defaults production: <<: *defaults
¶ ↑
Access your settings>> RAILS_ENV => "development" >> Settings.cool => "#<Settingslogic::Settings ... >" >> Settings.cool.saweet => "nested settings" >> Settings.neat_setting => 800 >> Settings.awesome_setting => "Did you know 5 + 5 = 10?"
¶ ↑
Multiple settingssettings1 = Settings.new(:settings1) # looks for config/settings1.yml settings2 = Settings.new("settings2.yaml") # looks for settings2.yml settings2 = Settings.new("/abs/path/settings2.yaml") # looks for /abs/path/settings2.yml settings3 = Settings.new(:some_setting => "some value")
¶ ↑
ConfigureConfiguration is optional. See Settingslogic::Config for more details.
# config/initializers/settingslogic.rb Settingslogic::Config.configure do |config| config.file_name = :config # will look for config/config.yml config.file_name = "config" # will look for config config.file_name = "config.yaml" # will look for confg.yaml config.file_name = "/absolute/path/config.yml" # will look for /absolute/path/config.yml end
Copyright © 2008 Ben Johnson of Binary Logic, released under the MIT license