configutron 0.3.0 → 0.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README.markdown +13 -10
- data/VERSION +1 -1
- data/lib/configutron.rb +3 -2
- data/spec/configutron_spec.rb +5 -1
- data/spec/fake_yml_files.rb +2 -0
- metadata +1 -1
data/README.markdown
CHANGED
@@ -71,21 +71,24 @@ try it out:
|
|
71
71
|
>> App.variable
|
72
72
|
=> "value"
|
73
73
|
|
74
|
+
also
|
75
|
+
----
|
76
|
+
* erb works
|
77
|
+
|
74
78
|
inspiration
|
75
79
|
-----------
|
76
|
-
*
|
77
|
-
*
|
80
|
+
* [Christopher J. Bottaro](http://github.com/cjbottaro/app_config/)'s app_config
|
81
|
+
* [Brian Smith](http://swig505.com)
|
78
82
|
|
79
83
|
note on patches/pull requests
|
80
84
|
-----------------------------
|
81
|
-
*
|
82
|
-
*
|
83
|
-
*
|
84
|
-
|
85
|
-
*
|
86
|
-
|
87
|
-
*
|
88
|
-
|
85
|
+
* fork the project.
|
86
|
+
* make your feature addition or bug fix.
|
87
|
+
* add tests for it. this is important so i don't break it in a
|
88
|
+
future version unintentionally.
|
89
|
+
* commit, do not mess with rakefile, version, or history.
|
90
|
+
(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)
|
91
|
+
* send me a pull request. bonus points for topic branches.
|
89
92
|
|
90
93
|
copyright
|
91
94
|
---------
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.3.
|
1
|
+
0.3.1
|
data/lib/configutron.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
require 'yaml'
|
2
2
|
require 'ostruct'
|
3
|
+
require 'erb'
|
3
4
|
require 'core_ext'
|
4
5
|
|
5
6
|
module Configutron
|
@@ -23,9 +24,9 @@ module Configutron
|
|
23
24
|
env_settings_path = File.expand_path("#{RAILS_ROOT}/config/settings/#{RAILS_ENV}.yml")
|
24
25
|
|
25
26
|
if File.exist?(settings_path)
|
26
|
-
@configutron = YAML.
|
27
|
+
@configutron = YAML.load(ERB.new(File.read(settings_path)).result)[RAILS_ENV].symbolize_keys
|
27
28
|
elsif File.exists?(env_settings_path)
|
28
|
-
@configutron = YAML.
|
29
|
+
@configutron = YAML.load(ERB.new(File.read(env_settings_path)).result).symbolize_keys
|
29
30
|
else
|
30
31
|
raise IOError, "Create either config/settings.yml or config/settings/RAILS_ENV.yml"
|
31
32
|
end
|
data/spec/configutron_spec.rb
CHANGED
@@ -59,6 +59,10 @@ describe Configutron do
|
|
59
59
|
Configutron.my_hash.one.should == 1
|
60
60
|
Configutron.my_hash.two.should == 2
|
61
61
|
end
|
62
|
+
|
63
|
+
specify "erb values work" do
|
64
|
+
Configutron.my_erb_variable.should == 3
|
65
|
+
end
|
62
66
|
end
|
63
67
|
|
64
68
|
describe "nested settings" do
|
@@ -71,6 +75,6 @@ describe Configutron do
|
|
71
75
|
Configutron.four.five.six.should == 6
|
72
76
|
end
|
73
77
|
end
|
74
|
-
end
|
78
|
+
end
|
75
79
|
end
|
76
80
|
end
|
data/spec/fake_yml_files.rb
CHANGED