dot_hash 0.5.5 → 0.5.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +2 -2
- data/README.md +4 -0
- data/lib/dot_hash/hash_loader.rb +1 -1
- data/lib/dot_hash/properties.rb +4 -4
- data/lib/dot_hash/version.rb +1 -1
- data/test/dot_hash/properties_test.rb +38 -0
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4880ebd3cfd60e9c73204ddfc44ca99602a56e47
|
4
|
+
data.tar.gz: aa6a8682da49c2cb0757ea72864967031731b414
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3a9f94f58436916025f0218d2167265b2ff613bf1f377cc130947baef331ebcb73f4d483e86df51870ed2ff51f19d7e8add24362a7031329cb171d1667f95675
|
7
|
+
data.tar.gz: 633e130bd4032bda87ccfed2c1400fa2b4dd139647bcc71edaae9391c1ac90393efa8889adfa1fedb2cc674974d99ad6bac4dcf37d097fb6854250d4fbf00a37
|
data/.travis.yml
CHANGED
data/README.md
CHANGED
@@ -38,3 +38,7 @@ properties["color"] # returns "red", can be used like a hash with symbol keys
|
|
38
38
|
3. Commit your changes (`git commit -am 'Added some feature'`)
|
39
39
|
4. Push to the branch (`git push origin my-new-feature`)
|
40
40
|
5. Create new Pull Request
|
41
|
+
|
42
|
+
|
43
|
+
[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/3den/dot_hash/trend.png)](https://bitdeli.com/free "Bitdeli Badge")
|
44
|
+
|
data/lib/dot_hash/hash_loader.rb
CHANGED
data/lib/dot_hash/properties.rb
CHANGED
@@ -15,8 +15,8 @@ module DotHash
|
|
15
15
|
end
|
16
16
|
end
|
17
17
|
|
18
|
-
def
|
19
|
-
has_key?(key) or super
|
18
|
+
def respond_to_missing?(key, *)
|
19
|
+
has_key?(key) or super
|
20
20
|
end
|
21
21
|
|
22
22
|
def to_s
|
@@ -34,8 +34,8 @@ module DotHash
|
|
34
34
|
private
|
35
35
|
|
36
36
|
def has_key?(key)
|
37
|
-
hash.has_key?(key.
|
38
|
-
hash.has_key?(key.
|
37
|
+
hash.has_key?(key.to_s) or
|
38
|
+
hash.has_key?(key.to_sym) or
|
39
39
|
hash.respond_to?(key)
|
40
40
|
end
|
41
41
|
|
data/lib/dot_hash/version.rb
CHANGED
@@ -128,5 +128,43 @@ module DotHash
|
|
128
128
|
end
|
129
129
|
end
|
130
130
|
|
131
|
+
describe '#method' do
|
132
|
+
before do
|
133
|
+
@properties = Properties.new speed: "100",
|
134
|
+
info: {name: "Eden"},
|
135
|
+
"color" => "#00FFBB"
|
136
|
+
end
|
137
|
+
|
138
|
+
it 'has a capturable method for a simple property' do
|
139
|
+
@properties.method(:speed).call.must_equal "100"
|
140
|
+
end
|
141
|
+
|
142
|
+
it 'has a capturable method for a nested property' do
|
143
|
+
@properties.info.method(:name).call.must_equal "Eden"
|
144
|
+
@properties.method(:info).call.name.must_equal "Eden"
|
145
|
+
end
|
146
|
+
|
147
|
+
it 'has a capturable method for a string property' do
|
148
|
+
@properties.method(:color).call.must_equal "#00FFBB"
|
149
|
+
end
|
150
|
+
|
151
|
+
it 'does not have a capturable method for a missing property' do
|
152
|
+
lambda do
|
153
|
+
@properties.method(:power)
|
154
|
+
end.must_raise(NameError)
|
155
|
+
end
|
156
|
+
|
157
|
+
it 'has a capturable method for public hash methods' do
|
158
|
+
@properties.method(:keys).must_be_kind_of Method
|
159
|
+
end
|
160
|
+
|
161
|
+
it 'has a capturable method for public methods' do
|
162
|
+
hash_method = @properties.method(:hash)
|
163
|
+
hash_method.must_be_kind_of Method
|
164
|
+
# not Object#hash or Properties#hash#hash
|
165
|
+
hash_method.call.wont_be_kind_of Numeric
|
166
|
+
end
|
167
|
+
end
|
168
|
+
|
131
169
|
end
|
132
170
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dot_hash
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Marcelo Eden
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2014-02-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -73,7 +73,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
73
73
|
version: '0'
|
74
74
|
requirements: []
|
75
75
|
rubyforge_project:
|
76
|
-
rubygems_version: 2.
|
76
|
+
rubygems_version: 2.1.10
|
77
77
|
signing_key:
|
78
78
|
specification_version: 4
|
79
79
|
summary: Converts hash.to_properties so you can access values using properties.some_key
|