conf 0.0.9 → 0.0.10
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 +1 -1
- data/conf.gemspec +1 -1
- data/lib/conf.rb +6 -1
- data/spec/conf_spec.rb +10 -2
- metadata +2 -2
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.10
|
data/conf.gemspec
CHANGED
data/lib/conf.rb
CHANGED
@@ -29,11 +29,16 @@ class Conf
|
|
29
29
|
|
30
30
|
def method_missing(meth, *args, &blk)
|
31
31
|
m = meth.to_s
|
32
|
-
|
32
|
+
|
33
|
+
if m =~ /^to_/
|
34
|
+
super
|
35
|
+
elsif m =~ /^(\w+)=/ || args.size == 1
|
36
|
+
# setter
|
33
37
|
@__root__.check_lock
|
34
38
|
key = [@__key__, $1 || m].compact.join(".")
|
35
39
|
@__root__[key] = ConfigValue.create(@__root__, key, args.first)
|
36
40
|
else
|
41
|
+
# getter
|
37
42
|
key = [@__key__, m].compact.join(".")
|
38
43
|
|
39
44
|
obj = @__root__.data[key]
|
data/spec/conf_spec.rb
CHANGED
@@ -121,11 +121,19 @@ describe "Conf" do
|
|
121
121
|
child.section("foo.bar").should == {"foo.bar.baz" => 1, "foo.bar.bah" => 2}
|
122
122
|
end
|
123
123
|
|
124
|
-
it "should handle nesting under existing values" do
|
125
|
-
Conf.define(:tmp) do
|
124
|
+
it "should handle nesting under existing (String) values" do
|
125
|
+
c = Conf.define(:tmp) do
|
126
126
|
foo "bar"
|
127
127
|
foo.bar "baz"
|
128
128
|
end
|
129
|
+
|
130
|
+
c.foo.should == "bar"
|
131
|
+
c.foo.bar.should == "baz"
|
132
|
+
end
|
133
|
+
|
134
|
+
it "raises NoMethodError for to_ary" do
|
135
|
+
c = Conf.define(:tmp) { foo "bar" }
|
136
|
+
lambda { c.foo.to_ary }.should raise_error(NoMethodError)
|
129
137
|
end
|
130
138
|
|
131
139
|
end
|