settingslogic 2.0.2 → 2.0.3
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.yml +2 -2
- data/lib/settingslogic.rb +16 -5
- data/settingslogic.gemspec +2 -2
- data/spec/settings.yml +11 -1
- data/spec/settingslogic_spec.rb +15 -2
- metadata +2 -2
data/VERSION.yml
CHANGED
data/lib/settingslogic.rb
CHANGED
@@ -54,14 +54,25 @@ class Settingslogic < Hash
|
|
54
54
|
end
|
55
55
|
end
|
56
56
|
|
57
|
-
|
57
|
+
module EigenMethodDefiner # :nodoc:
|
58
58
|
def method_missing(name, *args, &block)
|
59
59
|
if key?(name.to_s)
|
60
|
-
|
61
|
-
self.
|
62
|
-
|
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
|
-
|
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
|
data/settingslogic.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{settingslogic}
|
8
|
-
s.version = "2.0.
|
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-
|
12
|
+
s.date = %q{2009-09-01}
|
13
13
|
s.email = %q{bjohnson@binarylogic.com}
|
14
14
|
s.extra_rdoc_files = [
|
15
15
|
"LICENSE",
|
data/spec/settings.yml
CHANGED
data/spec/settingslogic_spec.rb
CHANGED
@@ -6,13 +6,21 @@ describe "Settingslogic" do
|
|
6
6
|
end
|
7
7
|
|
8
8
|
it "should access settings" do
|
9
|
-
Settings.
|
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
|
-
|
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.
|
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-
|
12
|
+
date: 2009-09-01 00:00:00 -05:00
|
13
13
|
default_executable:
|
14
14
|
dependencies: []
|
15
15
|
|