Skip to content
Newer
Older
100644 70 lines (47 sloc) 2.12 KB
8007ac0 @binarylogic Initial commit
binarylogic authored Oct 30, 2008
1 = Settingasm
2
3 Settingasm is my personal solution to application wide settings that uses an ERB enabled YAML file. It's pretty simple and straightforward, which is why I like it. I decided to go ahead and share it with the world.
4
5 So here is my question to you.....is Settingasm a great settings solution or the greatest?
6
aee3f70 @binarylogic Change Setting to Settings
binarylogic authored Oct 30, 2008
7 == Create your settings
8007ac0 @binarylogic Initial commit
binarylogic authored Oct 31, 2008
8
a114da8 @binarylogic Fix readme errors
binarylogic authored Oct 31, 2008
9 By default Settingasm tries to load config/application.yml. This is just a typical YAML file, notice ERB is allowed.
8007ac0 @binarylogic Initial commit
binarylogic authored Oct 31, 2008
10
11 # app/config/application.yml
12 defaults: &defaults
a114da8 @binarylogic Fix readme errors
binarylogic authored Oct 31, 2008
13 cool:
8007ac0 @binarylogic Initial commit
binarylogic authored Oct 31, 2008
14 saweet: nested settings
15 neat_setting: 24
16 awesome_setting: <%= "Did you know 5 + 5 = " + (5 + 5) + "?" %>
17
18 development:
19 <<: *defaults
20 neat_setting: 800
21
22 test:
23 <<: *defaults
24
25 production:
26 <<: *defaults
27
28 == Access your settings
29
30 >> RAILS_ENV
31 => "development"
32
aee3f70 @binarylogic Change Setting to Settings
binarylogic authored Oct 31, 2008
33 >> Settings.cool
a114da8 @binarylogic Fix readme errors
binarylogic authored Oct 31, 2008
34 => "#<Settingasm::Settings ... >"
8007ac0 @binarylogic Initial commit
binarylogic authored Oct 31, 2008
35
aee3f70 @binarylogic Change Setting to Settings
binarylogic authored Oct 31, 2008
36 >> Settings.cool.saweet
8007ac0 @binarylogic Initial commit
binarylogic authored Oct 31, 2008
37 => "nested settings"
38
a431fb4 @binarylogic Fixed readme typos
binarylogic authored Oct 31, 2008
39 >> Settings.neat_setting
8007ac0 @binarylogic Initial commit
binarylogic authored Oct 31, 2008
40 => 800
41
aee3f70 @binarylogic Change Setting to Settings
binarylogic authored Oct 31, 2008
42 >> Settings.awesome_setting
8007ac0 @binarylogic Initial commit
binarylogic authored Oct 31, 2008
43 => "Did you know 5 + 5 = 10?"
44
45 == Multiple settings
46
aee3f70 @binarylogic Change Setting to Settings
binarylogic authored Oct 31, 2008
47 settings1 = Settings.new(:settings1) # looks for config/settings1.yml
a431fb4 @binarylogic Fixed readme typos
binarylogic authored Oct 31, 2008
48 settings2 = Settings.new("settings2.yaml") # looks for settings2.yml
49 settings2 = Settings.new("/abs/path/settings2.yaml") # looks for /abs/path/settings2.yml
aee3f70 @binarylogic Change Setting to Settings
binarylogic authored Oct 31, 2008
50 settings3 = Settings.new(:some_setting => "some value")
51
52 == Configure
53
54 Configuration is optional. See Settingasm::Config for more details.
55
56 # config/initializers/settingasm.rb
57 Settingasm::Config.configure do |config|
58 config.file_name = :config # will look for config/config.yml
59 config.file_name = "config" # will look for config
60 config.file_name = "config.yaml" # will look for confg.yaml
61 config.file_name = "/absolute/path/config.yml" # will look for /absolute/path/config.yaml
62 end
63
8007ac0 @binarylogic Initial commit
binarylogic authored Oct 31, 2008
64 == Helpful links
65
6ddd493 @binarylogic Updated readme
binarylogic authored Oct 30, 2008
66 * <b>Documentation:</b> http://settingasm.rubyforge.org (as soon as ruby forge approves my project)
8007ac0 @binarylogic Initial commit
binarylogic authored Oct 31, 2008
67 * <b>Bugs / feature suggestions:</b> http://binarylogic.lighthouseapp.com/projects/19028-settingasm
68
69
70 Copyright (c) 2008 {Ben Johnson}[http://github.com/binarylogic] of {Binary Logic}[http://www.binarylogic.com], released under the MIT license
Something went wrong with that request. Please try again.