singlettings 0.0.2 → 0.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.
- checksums.yaml +4 -4
- data/README.md +10 -0
- data/lib/singlettings/base.rb +10 -0
- data/lib/singlettings/version.rb +1 -1
- data/spec/singletting_spec.rb +30 -2
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 503b5c0b3f0ca714aac39b985ec5ac5904cec66f
|
4
|
+
data.tar.gz: 0a4bab476d36c958bfaea1fbb45ae5c4016a9f05
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c4408f496f349e594a5be5560bf03d7f8edd6153848e051b058aa022fd89af77b83fae252fdba8299f072a2b83083f5f3f1ea9b386f70a8ef6f17f859fb5fbdb
|
7
|
+
data.tar.gz: 14f7f051ee0f04ab19054f13daa6bdd799310403168ff5a04d4a991ea35cc3a7a89f48e177fb6b4c13b21598117c7f03eba2e1969ebebb45a05ad6b56cf95000
|
data/README.md
CHANGED
@@ -56,6 +56,10 @@ You can invoke the object by calling as a hash:
|
|
56
56
|
Setting["key1"] # => value1
|
57
57
|
Setting["key1"]["key2"] # => value2
|
58
58
|
Setting[:key1][:key2][:key3] # => value3
|
59
|
+
|
60
|
+
Setting.respond_to? :key1 # => true
|
61
|
+
Setting.key1.respond_to? :key2 # => true
|
62
|
+
|
59
63
|
```
|
60
64
|
|
61
65
|
Also by calling:
|
@@ -64,6 +68,12 @@ Also by calling:
|
|
64
68
|
Setting.key1.key2 # => value2
|
65
69
|
```
|
66
70
|
|
71
|
+
### Testing
|
72
|
+
|
73
|
+
- It can be tested by running ```$ rake rspec```. You can debug it by calling ```$ rake console``` as well.
|
74
|
+
|
75
|
+
- A rails 4.0 app called 'myapp' is included in the repo to test compatibility.
|
76
|
+
|
67
77
|
## Contributing
|
68
78
|
|
69
79
|
1. Fork it
|
data/lib/singlettings/base.rb
CHANGED
@@ -56,6 +56,11 @@ module Singlettings
|
|
56
56
|
raise NoSuchKeyError, "#{key} does not exist"
|
57
57
|
end
|
58
58
|
end
|
59
|
+
|
60
|
+
def respond_to_missing?(method, include_private = false)
|
61
|
+
current_branch.keys.include? method.to_s ||
|
62
|
+
(raise NoSuchKeyError, "#{method} does not exist")
|
63
|
+
end
|
59
64
|
end # class self
|
60
65
|
|
61
66
|
def initialize(directory_or_hash, default_namespace= nil)
|
@@ -103,6 +108,11 @@ module Singlettings
|
|
103
108
|
raise NoSuchKeyError, "#{key} does not exist"
|
104
109
|
end
|
105
110
|
end
|
111
|
+
|
112
|
+
def respond_to_missing?(method, include_private = false)
|
113
|
+
current_branch.keys.include? method.to_s ||
|
114
|
+
(raise NoSuchKeyError, "#{method} does not exist")
|
115
|
+
end
|
106
116
|
end
|
107
117
|
|
108
118
|
end
|
data/lib/singlettings/version.rb
CHANGED
data/spec/singletting_spec.rb
CHANGED
@@ -27,7 +27,7 @@ describe :Singlettings do
|
|
27
27
|
end
|
28
28
|
end
|
29
29
|
|
30
|
-
context "
|
30
|
+
context "keyword test" do
|
31
31
|
it "one level sample" do
|
32
32
|
DevelopmentSample["adapter"].should == "mysql2"
|
33
33
|
DevelopmentSample["encoding"].should == "utf8"
|
@@ -40,6 +40,20 @@ describe :Singlettings do
|
|
40
40
|
Sample[:development][:password].should == nil
|
41
41
|
end
|
42
42
|
end
|
43
|
+
|
44
|
+
context "response to method" do
|
45
|
+
it "one level sample" do
|
46
|
+
[:adapter, :encoding, :password].each do |method|
|
47
|
+
DevelopmentSample.should respond_to(method)
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
it "multiple level sample" do
|
52
|
+
[:adapter, :encoding, :password].each do |method|
|
53
|
+
Sample.development.should respond_to(method)
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
43
57
|
end
|
44
58
|
|
45
59
|
describe "instance level singlettings" do
|
@@ -62,7 +76,7 @@ describe :Singlettings do
|
|
62
76
|
end
|
63
77
|
end
|
64
78
|
|
65
|
-
context "
|
79
|
+
context "keyword test" do
|
66
80
|
it "one level sample" do
|
67
81
|
@development_settings["adapter"].should == "mysql2"
|
68
82
|
@development_settings["encoding"].should == "utf8"
|
@@ -75,5 +89,19 @@ describe :Singlettings do
|
|
75
89
|
@settings[:development][:password].should == nil
|
76
90
|
end
|
77
91
|
end
|
92
|
+
|
93
|
+
context "response to method" do
|
94
|
+
it "one level sample" do
|
95
|
+
[:adapter, :encoding, :password].each do |method|
|
96
|
+
@development_settings.should respond_to(method)
|
97
|
+
end
|
98
|
+
end
|
99
|
+
|
100
|
+
it "multiple level sample" do
|
101
|
+
[:adapter, :encoding, :password].each do |method|
|
102
|
+
@settings.development.should respond_to(method)
|
103
|
+
end
|
104
|
+
end
|
105
|
+
end
|
78
106
|
end
|
79
107
|
end
|