configa 0.0.2 → 0.0.3

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.
@@ -1,3 +1,3 @@
1
1
  module Configa
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
data/lib/configa.rb CHANGED
@@ -52,7 +52,6 @@ module Configa
52
52
 
53
53
  # Tree traverse
54
54
  def merge_yaml(yaml, cache={})
55
- cache = cache.dup
56
55
  yaml.each do |k,v|
57
56
  next unless Hash === v
58
57
  cache[k] ||= {}
@@ -60,9 +59,9 @@ module Configa
60
59
  end
61
60
  yaml.each do |k,v|
62
61
  next unless Hash === v
63
- v.each do |key, data|
62
+ v.each do |key, val|
64
63
  if cache[key]
65
- yaml[k][key] = cache[key].merge data if cache[key] != data
64
+ yaml[k][key] = cache[key].merge yaml[k][key] if cache[key] != val
66
65
  end
67
66
  end
68
67
  yaml[k] = merge_yaml(yaml[k], cache)
data/spec/config.yml CHANGED
@@ -18,6 +18,10 @@ production:
18
18
  username: admin
19
19
  password: strongone
20
20
 
21
+ users:
22
+ mysql:
23
+ password: password
24
+
21
25
  staging:
22
26
  prestaging:
23
27
  mysql:
@@ -11,11 +11,12 @@ describe Configa do
11
11
  dev = configa.instance_variable_get(:"@yaml")["development"]
12
12
  dev["mysql"]["adapter"].must_equal mysql["adapter"]
13
13
  dev["mysql"]["database"].must_equal "mysql_dev"
14
- proc{ configa.staging.prestaging.mysql.database}.must_raise Configa::UnknownKey
14
+ proc{ configa.staging.prestaging.mysql.port}.must_raise Configa::UnknownKey
15
15
  configa.staging.prestaging.mysql.adapter.must_equal "mysql"
16
16
  configa.staging.prestaging.users.mysql.adapter.must_equal "mysql"
17
17
  configa.staging.prestaging.users.mysql.username.must_equal "test"
18
18
  configa.staging.prestaging.users.mysql.database.must_equal "users"
19
+ configa.staging.prestaging.users.mysql.password.must_equal "password"
19
20
  end
20
21
 
21
22
  it "basic test for multi file config" do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: configa
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-09-05 00:00:00.000000000 Z
12
+ date: 2012-09-06 00:00:00.000000000 Z
13
13
  dependencies: []
14
14
  description: YAML configuration file parser
15
15
  email: