dacs 0.3.2 → 0.4.0

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.3.2
1
+ 0.4.0
@@ -7,4 +7,6 @@ require 'dacs/environment_source'
7
7
  require 'dacs/file_source'
8
8
  require 'dacs/default_source'
9
9
  require 'dacs/environment_source'
10
+ require 'dacs/code_source'
10
11
  require 'dacs/app_config'
12
+
@@ -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,
@@ -0,0 +1,7 @@
1
+ module Dacs
2
+ class CodeSource
3
+ def to_s
4
+ "set in code"
5
+ end
6
+ end
7
+ end
@@ -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.3.2
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-22 00:00:00 -04:00
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