rails_config 0.1.4 → 0.1.5

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/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.4
1
+ 0.1.5
@@ -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
- unless h.is_a?(Hash)
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
- s.send( (k+'=').to_sym, __convert(v))
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)
@@ -0,0 +1,7 @@
1
+ prices:
2
+ type: hash
3
+ contents:
4
+ 1: 2.99
5
+ 5: 9.99
6
+ 15: 19.99
7
+ 30: 29.99
@@ -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: 19
4
+ hash: 17
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 1
9
- - 4
10
- version: 0.1.4
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-07 00:00:00 -07:00
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