confuse 0.1.1 → 0.1.2
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/lib/confuse/config.rb +2 -2
- data/lib/confuse/config_item.rb +1 -1
- data/lib/confuse/config_mixin.rb +13 -3
- data/lib/confuse/namespace.rb +4 -0
- data/lib/confuse/version.rb +1 -1
- metadata +4 -4
data/lib/confuse/config.rb
CHANGED
data/lib/confuse/config_item.rb
CHANGED
data/lib/confuse/config_mixin.rb
CHANGED
@@ -34,6 +34,15 @@ module Confuse
|
|
34
34
|
ns[rest_of_key, self]
|
35
35
|
end
|
36
36
|
|
37
|
+
def to_hash
|
38
|
+
namespaces.reduce({}) do |memo, (name, namespace)|
|
39
|
+
namespace.keys.each do |key|
|
40
|
+
memo["#{name}_#{key}"] = namespace[key, self]
|
41
|
+
end
|
42
|
+
memo
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
37
46
|
# We allow the namespace and the key to be concatenated with an '_', so this
|
38
47
|
# method is to search the possible substrings that could make up the
|
39
48
|
# namespace for a key.
|
@@ -78,8 +87,9 @@ module Confuse
|
|
78
87
|
|
79
88
|
def mixin_config!(config)
|
80
89
|
config.each do |key, value|
|
81
|
-
|
82
|
-
|
90
|
+
namespace_name = find_namespace(key) || :default
|
91
|
+
namespace = @namespaces[namespace_name]
|
92
|
+
if value.respond_to?(:keys)
|
83
93
|
# if its a hash, set each key in the hash as a config item in the
|
84
94
|
# namespace
|
85
95
|
value.each do |k, v|
|
@@ -87,7 +97,7 @@ module Confuse
|
|
87
97
|
end
|
88
98
|
else
|
89
99
|
# otherwise, set it directly in the namespace
|
90
|
-
namespace[key] = value
|
100
|
+
namespace[rest_of_key(key, namespace_name)] = value
|
91
101
|
end
|
92
102
|
end
|
93
103
|
end
|
data/lib/confuse/namespace.rb
CHANGED
data/lib/confuse/version.rb
CHANGED
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: confuse
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 31
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 1
|
9
|
-
-
|
10
|
-
version: 0.1.
|
9
|
+
- 2
|
10
|
+
version: 0.1.2
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Tom Chipchase
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2013-10-
|
18
|
+
date: 2013-10-04 00:00:00 Z
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
21
21
|
name: inifile
|