rails_config 0.1.4 → 0.1.5
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/lib/rails_config/options.rb +7 -4
- data/spec/fixtures/custom_types/hash.yml +7 -0
- data/spec/rails_config_spec.rb +18 -0
- metadata +5 -4
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.5
|
data/lib/rails_config/options.rb
CHANGED
@@ -41,13 +41,16 @@ module RailsConfig
|
|
41
41
|
# Recursively converts Hashes to Options (including Hashes inside Arrays)
|
42
42
|
def __convert(h) #:nodoc:
|
43
43
|
s = self.class.new
|
44
|
-
|
45
|
-
require 'ruby-debug';debugger
|
46
|
-
end
|
44
|
+
|
47
45
|
h.each do |k, v|
|
48
46
|
s.new_ostruct_member(k)
|
49
47
|
if v.is_a?(Hash)
|
50
|
-
|
48
|
+
if(v["type"] == "hash")
|
49
|
+
val = v["contents"]
|
50
|
+
else
|
51
|
+
val = __convert(v)
|
52
|
+
end
|
53
|
+
s.send( (k+'=').to_sym, val)
|
51
54
|
elsif v.is_a?(Array)
|
52
55
|
converted_array = v.collect { |e| e.instance_of?(Hash) ? __convert(e) : e }
|
53
56
|
s.send("#{k}=".to_sym, converted_array)
|
data/spec/rails_config_spec.rb
CHANGED
@@ -114,4 +114,22 @@ describe RailsConfig do
|
|
114
114
|
end
|
115
115
|
end
|
116
116
|
|
117
|
+
context "Settings with a type value of 'hash'" do
|
118
|
+
let(:config) do
|
119
|
+
files = [setting_path("custom_types/hash.yml")]
|
120
|
+
RailsConfig.load_files(files)
|
121
|
+
end
|
122
|
+
|
123
|
+
it "should turn that setting into a Real Hash" do
|
124
|
+
config.prices.should be_a(Hash)
|
125
|
+
end
|
126
|
+
|
127
|
+
it "should map the hash values correctly" do
|
128
|
+
config.prices[1].should == 2.99
|
129
|
+
config.prices[5].should == 9.99
|
130
|
+
config.prices[15].should == 19.99
|
131
|
+
config.prices[30].should == 29.99
|
132
|
+
end
|
133
|
+
end
|
134
|
+
|
117
135
|
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rails_config
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 17
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 1
|
9
|
-
-
|
10
|
-
version: 0.1.
|
9
|
+
- 5
|
10
|
+
version: 0.1.5
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Jacques Crocker
|
@@ -16,7 +16,7 @@ autorequire:
|
|
16
16
|
bindir: bin
|
17
17
|
cert_chain: []
|
18
18
|
|
19
|
-
date: 2010-09-
|
19
|
+
date: 2010-09-13 00:00:00 -07:00
|
20
20
|
default_executable:
|
21
21
|
dependencies:
|
22
22
|
- !ruby/object:Gem::Dependency
|
@@ -85,6 +85,7 @@ files:
|
|
85
85
|
- lib/rails_config/vendor/deep_merge.rb
|
86
86
|
- spec/fixtures/bool_override/config1.yml
|
87
87
|
- spec/fixtures/bool_override/config2.yml
|
88
|
+
- spec/fixtures/custom_types/hash.yml
|
88
89
|
- spec/fixtures/deep_merge/config1.yml
|
89
90
|
- spec/fixtures/deep_merge/config2.yml
|
90
91
|
- spec/fixtures/deep_merge2/config1.yml
|