dacs 0.3.2 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/lib/dacs.rb +2 -0
- data/lib/dacs/app_config.rb +13 -0
- data/lib/dacs/code_source.rb +7 -0
- data/spec/dacs/app_config_spec.rb +30 -0
- metadata +3 -2
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.4.0
|
data/lib/dacs.rb
CHANGED
data/lib/dacs/app_config.rb
CHANGED
@@ -144,6 +144,19 @@ module Dacs
|
|
144
144
|
end
|
145
145
|
end
|
146
146
|
|
147
|
+
def merge(new_values)
|
148
|
+
self.clone.merge!(new_values)
|
149
|
+
end
|
150
|
+
|
151
|
+
def merge!(new_values)
|
152
|
+
new_values.each_pair do |k,v|
|
153
|
+
self[k.to_s] = ConfiguredValue.new(
|
154
|
+
CodeSource.new,
|
155
|
+
k.to_s,
|
156
|
+
v)
|
157
|
+
end
|
158
|
+
end
|
159
|
+
|
147
160
|
def dump
|
148
161
|
Hirb::Helpers::AutoTable.render(
|
149
162
|
self.values,
|
@@ -199,6 +199,36 @@ module Dacs
|
|
199
199
|
end
|
200
200
|
end
|
201
201
|
|
202
|
+
context "with values set from a file + values merged in" do
|
203
|
+
before :each do
|
204
|
+
@construct.file("config/foo_app.yml") do |f|
|
205
|
+
YAML.dump({
|
206
|
+
'development'=>{
|
207
|
+
'bar' => 'file_bar',
|
208
|
+
'baz' => 'file_baz'
|
209
|
+
}
|
210
|
+
},
|
211
|
+
f)
|
212
|
+
end
|
213
|
+
AppConfig.init!(@app_name, :logger => @logger) do |config|
|
214
|
+
config.key 'bar', :default => "baz"
|
215
|
+
config.key 'baz', :default => "ribbit"
|
216
|
+
config.key 'buz', :default => "moo"
|
217
|
+
end
|
218
|
+
AppConfig.merge!(:baz => 'merge_baz', 'buz' => 'merge_buz')
|
219
|
+
end
|
220
|
+
|
221
|
+
it "should contain the merged values" do
|
222
|
+
AppConfig['baz'].should == "merge_baz"
|
223
|
+
AppConfig['buz'].should == "merge_buz"
|
224
|
+
end
|
225
|
+
|
226
|
+
it "should know the merged values were set explicitly in code" do
|
227
|
+
AppConfig.source('baz').should =~ /code/i
|
228
|
+
AppConfig.source('buz').should =~ /code/i
|
229
|
+
end
|
230
|
+
end
|
231
|
+
|
202
232
|
context "with a mix of default, file, and environment settings" do
|
203
233
|
before :each do
|
204
234
|
@construct.file("config/foo_app.yml") do |f|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dacs
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Devver, Inc.
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2010-03-
|
12
|
+
date: 2010-03-24 00:00:00 -04:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -73,6 +73,7 @@ files:
|
|
73
73
|
- example/example.yml
|
74
74
|
- lib/dacs.rb
|
75
75
|
- lib/dacs/app_config.rb
|
76
|
+
- lib/dacs/code_source.rb
|
76
77
|
- lib/dacs/configured_value.rb
|
77
78
|
- lib/dacs/default_source.rb
|
78
79
|
- lib/dacs/environment_source.rb
|