settingslogic 2.0.2 → 2.0.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,4 +1,4 @@
1
1
  ---
2
- :minor: 0
3
- :patch: 2
2
+ :patch: 3
4
3
  :major: 2
4
+ :minor: 0
@@ -54,14 +54,25 @@ class Settingslogic < Hash
54
54
  end
55
55
  end
56
56
 
57
- private
57
+ module EigenMethodDefiner # :nodoc:
58
58
  def method_missing(name, *args, &block)
59
59
  if key?(name.to_s)
60
- value = self[name.to_s].is_a?(Hash) ? self.class.new(self[name.to_s]) : self[name.to_s]
61
- self.class.send(:define_method, name) { value }
62
- send(name)
60
+ define_eigen_method(name.to_s)
61
+ value = self[name.to_s]
62
+ value.extend(EigenMethodDefiner) if value.is_a?(Hash)
63
+ value
63
64
  else
64
65
  super
65
66
  end
66
67
  end
67
- end
68
+
69
+ private
70
+
71
+ def define_eigen_method(name)
72
+ eigen_class = class << self; self; end
73
+ eigen_class.send(:define_method, name) { self[name] }
74
+ end
75
+ end
76
+
77
+ include EigenMethodDefiner
78
+ end
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{settingslogic}
8
- s.version = "2.0.2"
8
+ s.version = "2.0.3"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Ben Johnson of Binary Logic"]
12
- s.date = %q{2009-08-22}
12
+ s.date = %q{2009-09-01}
13
13
  s.email = %q{bjohnson@binarylogic.com}
14
14
  s.extra_rdoc_files = [
15
15
  "LICENSE",
@@ -1,6 +1,16 @@
1
1
  setting1:
2
2
  setting1_child: saweet
3
+ deep:
4
+ another: my value
5
+ child:
6
+ value: 2
3
7
 
4
8
  setting2: 5
5
9
  setting3: <%= 5 * 5 %>
6
- name: test
10
+ name: test
11
+
12
+ language:
13
+ haskell:
14
+ paradigm: functional
15
+ smalltalk:
16
+ paradigm: object oriented
@@ -6,13 +6,21 @@ describe "Settingslogic" do
6
6
  end
7
7
 
8
8
  it "should access settings" do
9
- Settings.setting1.should == {"setting1_child" => "saweet"}
9
+ Settings.setting2.should == 5
10
10
  end
11
11
 
12
12
  it "should access nested settings" do
13
13
  Settings.setting1.setting1_child.should == "saweet"
14
14
  end
15
15
 
16
+ it "should access deep nested settings" do
17
+ Settings.setting1.deep.another.should == "my value"
18
+ end
19
+
20
+ it "should access extra deep nested settings" do
21
+ Settings.setting1.deep.child.value.should == 2
22
+ end
23
+
16
24
  it "should enable erb" do
17
25
  Settings.setting3.should == 25
18
26
  end
@@ -20,4 +28,9 @@ describe "Settingslogic" do
20
28
  it "should namespace settings" do
21
29
  Settings2.setting1_child.should == "saweet"
22
30
  end
23
- end
31
+
32
+ it "should distinguish nested keys" do
33
+ Settings.language.haskell.paradigm.should == 'functional'
34
+ Settings.language.smalltalk.paradigm.should == 'object oriented'
35
+ end
36
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: settingslogic
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.2
4
+ version: 2.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ben Johnson of Binary Logic
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-08-22 00:00:00 -04:00
12
+ date: 2009-09-01 00:00:00 -05:00
13
13
  default_executable:
14
14
  dependencies: []
15
15