conf 0.0.9 → 0.0.10

Sign up to get free protection for your applications and to get access to all the features.
Files changed (5) hide show
  1. data/VERSION +1 -1
  2. data/conf.gemspec +1 -1
  3. data/lib/conf.rb +6 -1
  4. data/spec/conf_spec.rb +10 -2
  5. metadata +2 -2
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.9
1
+ 0.0.10
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{conf}
8
- s.version = "0.0.9"
8
+ s.version = "0.0.10"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Jari Bakken"]
@@ -29,11 +29,16 @@ class Conf
29
29
 
30
30
  def method_missing(meth, *args, &blk)
31
31
  m = meth.to_s
32
- if m =~ /^(\w+)=/ || args.size == 1
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]
@@ -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
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 0
8
- - 9
9
- version: 0.0.9
8
+ - 10
9
+ version: 0.0.10
10
10
  platform: ruby
11
11
  authors:
12
12
  - Jari Bakken