hash_pick 0.2.1 → 0.2.2
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/lib/hash_pick/version.rb +1 -1
- data/lib/hash_pick.rb +7 -4
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7dd8624c8171843a2eef1aff8cc3a36703a73ed8
|
4
|
+
data.tar.gz: 3e7e026f72fdbcf650ba94a1297250ae5400698a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz: '
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: '08237ef3fe7264baffb72f88d34645f50edd0864ac39aa7672d84740b2bfd167bce45447efe93bc4590784095a525296199d66f2079b9b884c8dcae691fd24e2'
|
7
|
+
data.tar.gz: 975e6f37633a6da46bd54ef97db4c3b390e2697d981421834576da98f6ae0a96d89e997fff8f9a93f84f164be811cd6b4a004a05fc6a31f6bda1ea21d1294c5a
|
data/lib/hash_pick/version.rb
CHANGED
data/lib/hash_pick.rb
CHANGED
@@ -61,8 +61,10 @@ module HashPick
|
|
61
61
|
# General form of hash path iteration
|
62
62
|
#
|
63
63
|
# Passes to +block+, the dictionary and hash key for each iteration of the hash path, using
|
64
|
-
# the return value of the block as the dictionary for the next iteration, or
|
65
|
-
#
|
64
|
+
# the return value of the block as the dictionary for the next iteration, or in the case of
|
65
|
+
# the last iteration, as the return value. If the block returns a non-dictionary in any but
|
66
|
+
# the last iteration, or if the block throws +:break+, iteration is aborted and +nil+ is
|
67
|
+
# returned.
|
66
68
|
#
|
67
69
|
# @example Complex hash path semantics
|
68
70
|
#
|
@@ -93,6 +95,7 @@ module HashPick
|
|
93
95
|
# an ordered list of path keys.
|
94
96
|
# @return [Object] the value of the last iteration.
|
95
97
|
# @return [nil] if +block+ throws +:break+ in any iteration.
|
98
|
+
# @return [nil] if +block+ returns a non-dictionary for any but the last iteration.
|
96
99
|
# @raise [ArgumentError] if +hash+ isn't a dictionary.
|
97
100
|
# @raise [ArgumentError] if +path+ isn't a list.
|
98
101
|
#
|
@@ -165,7 +168,7 @@ module HashPick
|
|
165
168
|
#
|
166
169
|
def self.symbol(hash, path)
|
167
170
|
assert_non_nil_path_keys(path)
|
168
|
-
|
171
|
+
pick(hash, path) { |acc, p| acc[p.to_sym] }
|
169
172
|
end
|
170
173
|
|
171
174
|
##
|
@@ -185,7 +188,7 @@ module HashPick
|
|
185
188
|
#
|
186
189
|
def self.string(hash, path)
|
187
190
|
assert_non_nil_path_keys(path)
|
188
|
-
|
191
|
+
pick(hash, path) { |acc, p| acc[p.to_s] }
|
189
192
|
end
|
190
193
|
|
191
194
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hash_pick
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sheldon Hearn
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-02-
|
11
|
+
date: 2017-02-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|