configa 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/configa/version.rb +1 -1
- data/lib/configa.rb +2 -3
- data/spec/config.yml +4 -0
- data/spec/configa/configa_spec.rb +2 -1
- metadata +2 -2
data/lib/configa/version.rb
CHANGED
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,
|
62
|
+
v.each do |key, val|
|
64
63
|
if cache[key]
|
65
|
-
yaml[k][key] = cache[key].merge
|
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
@@ -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.
|
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.
|
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-
|
12
|
+
date: 2012-09-06 00:00:00.000000000 Z
|
13
13
|
dependencies: []
|
14
14
|
description: YAML configuration file parser
|
15
15
|
email:
|