mc-settings 0.1.3 → 0.1.4
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/lib/setting.rb +4 -3
- data/mc-settings.gemspec +3 -2
- data/spec/fixtures/shipping.yml +34 -0
- data/spec/mc_settings_spec.rb +17 -0
- metadata +5 -4
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.4
|
data/lib/setting.rb
CHANGED
@@ -138,9 +138,10 @@ class Setting
|
|
138
138
|
else
|
139
139
|
v
|
140
140
|
end
|
141
|
-
|
142
|
-
|
143
|
-
|
141
|
+
if out.is_a?(Hash) && !args.empty?
|
142
|
+
collapse_hashes(out, args)
|
143
|
+
elsif out.is_a?(Hash) && out.has_key?('default')
|
144
|
+
out['default']
|
144
145
|
else
|
145
146
|
out
|
146
147
|
end
|
data/mc-settings.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{mc-settings}
|
8
|
-
s.version = "0.1.
|
8
|
+
s.version = "0.1.4"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Edwin Cruz", "Colin Shield"]
|
12
|
-
s.date = %q{2011-06-
|
12
|
+
s.date = %q{2011-06-07}
|
13
13
|
s.description = %q{implement custom keys indenendently of environment}
|
14
14
|
s.email = %q{rubydev@modcloth.com}
|
15
15
|
s.extra_rdoc_files = [
|
@@ -29,6 +29,7 @@ Gem::Specification.new do |s|
|
|
29
29
|
"mc-settings.gemspec",
|
30
30
|
"spec/fixtures/joes-colors.yml",
|
31
31
|
"spec/fixtures/sample.yml",
|
32
|
+
"spec/fixtures/shipping.yml",
|
32
33
|
"spec/mc_settings_spec.rb",
|
33
34
|
"spec/spec_helper.rb",
|
34
35
|
"spec/support/settings_helper.rb"
|
@@ -0,0 +1,34 @@
|
|
1
|
+
shipping_config:
|
2
|
+
default: Defaulted
|
3
|
+
domestic:
|
4
|
+
service: MyService
|
5
|
+
countries:
|
6
|
+
- "US"
|
7
|
+
non_shippable_regions:
|
8
|
+
- "US-AS"
|
9
|
+
- "US-GU"
|
10
|
+
- "US-MP"
|
11
|
+
- "US-PR"
|
12
|
+
- "US-UM"
|
13
|
+
- "US-VI"
|
14
|
+
- "US-AF"
|
15
|
+
- "US-AA"
|
16
|
+
- "US-AC"
|
17
|
+
- "US-AE"
|
18
|
+
- "US-AM"
|
19
|
+
- "US-AP"
|
20
|
+
- "US-FM"
|
21
|
+
- "US-PW"
|
22
|
+
- "US-MH"
|
23
|
+
international:
|
24
|
+
service: Foo
|
25
|
+
countries:
|
26
|
+
- "GU"
|
27
|
+
- "VI"
|
28
|
+
- "AS"
|
29
|
+
- "MP"
|
30
|
+
- "UM"
|
31
|
+
- "FR"
|
32
|
+
- "GR"
|
33
|
+
- "RU"
|
34
|
+
shipping_carrier: Bar
|
data/spec/mc_settings_spec.rb
CHANGED
@@ -126,4 +126,21 @@ describe Setting do
|
|
126
126
|
end
|
127
127
|
|
128
128
|
end
|
129
|
+
context "Complex nested configs" do
|
130
|
+
before :each do
|
131
|
+
Setting.reload(
|
132
|
+
:path => File.join(File.dirname(__FILE__)) + '/fixtures',
|
133
|
+
:files => ['shipping.yml']
|
134
|
+
)
|
135
|
+
end
|
136
|
+
it "should build correct tree with arrays and default values " do
|
137
|
+
Setting.shipping_config.should == "Defaulted"
|
138
|
+
Setting.shipping_config(:domestic, :non_shippable_regions).first.should == "US-AS"
|
139
|
+
Setting.shipping_config(:international, :service).should == 'Foo'
|
140
|
+
Setting.shipping_config(:international, :countries).size.should > 0
|
141
|
+
Setting.shipping_config(:international, :shipping_carrier).should == 'Bar'
|
142
|
+
#backward compatibility:
|
143
|
+
Setting.shipping_config(:domestic)['non_shippable_regions'].size.should > 0
|
144
|
+
end
|
145
|
+
end
|
129
146
|
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mc-settings
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 19
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 1
|
9
|
-
-
|
10
|
-
version: 0.1.
|
9
|
+
- 4
|
10
|
+
version: 0.1.4
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Edwin Cruz
|
@@ -16,7 +16,7 @@ autorequire:
|
|
16
16
|
bindir: bin
|
17
17
|
cert_chain: []
|
18
18
|
|
19
|
-
date: 2011-06-
|
19
|
+
date: 2011-06-07 00:00:00 -05:00
|
20
20
|
default_executable:
|
21
21
|
dependencies:
|
22
22
|
- !ruby/object:Gem::Dependency
|
@@ -115,6 +115,7 @@ files:
|
|
115
115
|
- mc-settings.gemspec
|
116
116
|
- spec/fixtures/joes-colors.yml
|
117
117
|
- spec/fixtures/sample.yml
|
118
|
+
- spec/fixtures/shipping.yml
|
118
119
|
- spec/mc_settings_spec.rb
|
119
120
|
- spec/spec_helper.rb
|
120
121
|
- spec/support/settings_helper.rb
|