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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 322482c93381a58cef01d8c63506852217c9c82c
4
- data.tar.gz: b235f02b98eb9a0459ce6e25dc700f7ecb7cad14
3
+ metadata.gz: 4880ebd3cfd60e9c73204ddfc44ca99602a56e47
4
+ data.tar.gz: aa6a8682da49c2cb0757ea72864967031731b414
5
5
  SHA512:
6
- metadata.gz: 4c937e870e8cf7937c4e74d5d661fd8ab3281cde75e08c06b88e9ff855c05381c7c8ce19a7e9ff80833c31afef517c87a609937c432c525496b0b36b0d50a1ea
7
- data.tar.gz: 8f00f82bbf141b8e192c8330177c2717db6f5a1fc7699ea27e9d5feb300d3484068e9af4cd65c5423fddb6f9cf0c41160c8527de3ecc6dec0f73cc5cddc1a4fb
6
+ metadata.gz: 3a9f94f58436916025f0218d2167265b2ff613bf1f377cc130947baef331ebcb73f4d483e86df51870ed2ff51f19d7e8add24362a7031329cb171d1667f95675
7
+ data.tar.gz: 633e130bd4032bda87ccfed2c1400fa2b4dd139647bcc71edaae9391c1ac90393efa8889adfa1fedb2cc674974d99ad6bac4dcf37d097fb6854250d4fbf00a37
@@ -1,4 +1,4 @@
1
1
  language: ruby
2
2
  rvm:
3
- - 1.9.3-p194
4
- - 2.0.0-p0
3
+ - 1.9.3
4
+ - 2.0.0
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
+
@@ -46,7 +46,7 @@ module DotHash
46
46
  end
47
47
 
48
48
  def get_hash_from_directory(directory)
49
- Dir["#{directory}/**/*"].inject({}) do |hash, file|
49
+ Dir["#{directory}/**/*"].sort.inject({}) do |hash, file|
50
50
  merge_hashes hash, get_hash_from_file(file)
51
51
  end
52
52
  end
@@ -15,8 +15,8 @@ module DotHash
15
15
  end
16
16
  end
17
17
 
18
- def respond_to?(key)
19
- has_key?(key) or super(key)
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.to_sym) or
38
- hash.has_key?(key.to_s) or
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
 
@@ -1,3 +1,3 @@
1
1
  module DotHash
2
- VERSION = "0.5.5"
2
+ VERSION = "0.5.6"
3
3
  end
@@ -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.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: 2013-05-15 00:00:00.000000000 Z
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.0.3
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