singlettings 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 61a5391f730590158f913a9e2b7143fcb9985408
4
- data.tar.gz: 20c11138eb0c8873d266b508bf0dc0f35c66e0ab
3
+ metadata.gz: 503b5c0b3f0ca714aac39b985ec5ac5904cec66f
4
+ data.tar.gz: 0a4bab476d36c958bfaea1fbb45ae5c4016a9f05
5
5
  SHA512:
6
- metadata.gz: aebf3b18a23d2f863e5e9f799da83027e423712afa17dff8e7f6a581eacf76d83b92f19a7d0161366e6c4c287de8a6d87bcb2fb909d0630c9a69ba6625b8d6b1
7
- data.tar.gz: f079732f7edb8e2d8d4d9bd47a458377da26c7c4e0c7288abb93e830a94b436f51bdbb7b49b6f856d9b12931dc325049160c90f7e5cb37fb2a916131da6366da
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
@@ -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
@@ -1,3 +1,3 @@
1
1
  module Singlettings
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
@@ -27,7 +27,7 @@ describe :Singlettings do
27
27
  end
28
28
  end
29
29
 
30
- context "method test" do
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 "method test" do
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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: singlettings
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jingkai He