mc-settings 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 +1 -1
- data/lib/setting.rb +2 -1
- data/mc-settings.gemspec +2 -2
- data/spec/fixtures/shipping.yml +4 -2
- data/spec/mc_settings_spec.rb +14 -0
- data/spec/support/settings_helper.rb +4 -4
- metadata +4 -4
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.5
|
data/lib/setting.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
require 'singleton'
|
2
2
|
require 'yaml'
|
3
|
+
require 'erb'
|
3
4
|
|
4
5
|
class Hash
|
5
6
|
def recursive_merge!(other)
|
@@ -168,7 +169,7 @@ class Setting
|
|
168
169
|
|
169
170
|
files.flatten.each do |file|
|
170
171
|
begin
|
171
|
-
@available_settings.recursive_merge!(YAML::load(
|
172
|
+
@available_settings.recursive_merge!(YAML::load(ERB.new(IO.read(file)).result) || {}) if File.exists?(file)
|
172
173
|
rescue Exception => e
|
173
174
|
raise FileError.new("Error parsing file #{file}, with: #{e.message}")
|
174
175
|
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.5"
|
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-
|
12
|
+
s.date = %q{2011-07-14}
|
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 = [
|
data/spec/fixtures/shipping.yml
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
shipping_config:
|
2
|
-
default: Defaulted
|
2
|
+
default: <%= 'Defaulted' %>
|
3
3
|
domestic:
|
4
4
|
service: MyService
|
5
5
|
countries:
|
@@ -31,4 +31,6 @@ shipping_config:
|
|
31
31
|
- "FR"
|
32
32
|
- "GR"
|
33
33
|
- "RU"
|
34
|
-
shipping_carrier: Bar
|
34
|
+
shipping_carrier: Bar
|
35
|
+
number: <%= 5%>
|
36
|
+
stringified: <%= nil || "stringified"%>
|
data/spec/mc_settings_spec.rb
CHANGED
@@ -143,4 +143,18 @@ describe Setting do
|
|
143
143
|
Setting.shipping_config(:domestic)['non_shippable_regions'].size.should > 0
|
144
144
|
end
|
145
145
|
end
|
146
|
+
|
147
|
+
context "Ruby code inside yml file" do
|
148
|
+
before :each do
|
149
|
+
Setting.reload(
|
150
|
+
:path => File.join(File.dirname(__FILE__)) + '/fixtures',
|
151
|
+
:files => ['shipping.yml']
|
152
|
+
)
|
153
|
+
end
|
154
|
+
it "should interpret ruby code and put correct values" do
|
155
|
+
Setting.shipping_config.should == "Defaulted"
|
156
|
+
Setting.number == 5
|
157
|
+
Setting.stringified == "stringified"
|
158
|
+
end
|
159
|
+
end
|
146
160
|
end
|
@@ -50,10 +50,10 @@ CONTENT
|
|
50
50
|
|
51
51
|
File.stub!(:exists?).and_return(true)
|
52
52
|
File.stub!(:exists?).with("config/settings/environments/development.yml").and_return(false)
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
53
|
+
IO.stub!(:read).with("config/settings/default.yml").and_return(defaults)
|
54
|
+
IO.stub!(:read).with("config/settings/environments/test.yml").and_return(test)
|
55
|
+
IO.stub!(:read).with("config/settings/local/custom.yml").and_return(custom)
|
56
|
+
IO.stub!(:read).with("config/settings/local/empty.yml").and_return(empty)
|
57
57
|
|
58
58
|
Dir.stub!(:glob).and_return(["config/settings/local/empty.yml", "config/settings/local/custom.yml"])
|
59
59
|
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: 17
|
5
5
|
prerelease:
|
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
|
- Edwin Cruz
|
@@ -16,7 +16,7 @@ autorequire:
|
|
16
16
|
bindir: bin
|
17
17
|
cert_chain: []
|
18
18
|
|
19
|
-
date: 2011-
|
19
|
+
date: 2011-07-14 00:00:00 -05:00
|
20
20
|
default_executable:
|
21
21
|
dependencies:
|
22
22
|
- !ruby/object:Gem::Dependency
|