singlettings 0.0.4 → 0.0.5
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/changes.md +3 -0
- data/lib/singlettings/base.rb +15 -8
- data/lib/singlettings/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 691b5a753bda4746f95ff0fa30254c72ab35f7bf
|
4
|
+
data.tar.gz: 555694c87632d93ecd1b4084c8ccfe333a9bdcaf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 66d366df9f4ab81ad9a03ad9bf122b9a919d27a1174b2859b9139dc0093c015e8f7f93af96b3221d1a09e7423cf81d30a811636c83a7c5f1eb3e7d1de9c7b1e0
|
7
|
+
data.tar.gz: 9831baa0ee9531b02a8728f2c6433d464056f95939a78af57ad5ad7adbc15f1c7a057ba454020893f2825d95a3c04946dae74b06df345e2deb190f4261b60138
|
data/changes.md
ADDED
data/lib/singlettings/base.rb
CHANGED
@@ -5,6 +5,7 @@ require 'erb'
|
|
5
5
|
module Singlettings
|
6
6
|
class Base < Hash
|
7
7
|
attr_reader :source, :ns
|
8
|
+
|
8
9
|
class << self
|
9
10
|
# Basic Usage of source in class
|
10
11
|
# source "config/setting.yml"
|
@@ -47,11 +48,14 @@ module Singlettings
|
|
47
48
|
key = method.to_s
|
48
49
|
if current_branch.keys.include? key
|
49
50
|
value = current_branch[key]
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
51
|
+
|
52
|
+
result = value.is_a?(Hash) ? self.new(value) : value
|
53
|
+
|
54
|
+
self.instance_eval do
|
55
|
+
define_singleton_method(key){ result }
|
54
56
|
end
|
57
|
+
|
58
|
+
result
|
55
59
|
else
|
56
60
|
raise NoSuchKeyError, "#{key} does not exist"
|
57
61
|
end
|
@@ -99,11 +103,14 @@ module Singlettings
|
|
99
103
|
key = method.to_s
|
100
104
|
if current_branch.keys.include? key
|
101
105
|
value = current_branch[key]
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
+
|
107
|
+
result = value.is_a?(Hash) ? self.class.new(value) : value
|
108
|
+
|
109
|
+
self.class.class_eval do
|
110
|
+
define_method(key){ result }
|
106
111
|
end
|
112
|
+
|
113
|
+
result
|
107
114
|
else
|
108
115
|
raise NoSuchKeyError, "#{key} does not exist"
|
109
116
|
end
|
data/lib/singlettings/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: singlettings
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jingkai He
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-01-
|
11
|
+
date: 2014-01-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -64,6 +64,7 @@ files:
|
|
64
64
|
- LICENSE.txt
|
65
65
|
- README.md
|
66
66
|
- Rakefile
|
67
|
+
- changes.md
|
67
68
|
- lib/singlettings.rb
|
68
69
|
- lib/singlettings/base.rb
|
69
70
|
- lib/singlettings/exceptions.rb
|