the_hash_whisperer 0.0.0 → 0.0.1
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/the_hash_whisperer.rb +3 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 83bed796abff012203695cf253e058ffea3d2bfa7e3bb70a59646fc7abd35152
|
4
|
+
data.tar.gz: fb41a6613634d8cc9785101910448dbb179fb35e2641ef62214e7c8da8623f58
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fdd125842a8d660b9bfd6843680f6c00b6a179b8e5c819e8bfb11adc5f8bf6af7af2d647863e78b27470d2073c9614d67591ae0f2f541ba352eff1bbeb92bad0
|
7
|
+
data.tar.gz: 025c9d1c0bd1e8ff20bb10054fb1db8906a3230b6060a4ed175c295ddafd84d0ddbe933f4fdb0cdc7c2a9c902ea06742f0125cdf97c8c86fe3b3dd34f58a4ed3
|
data/lib/the_hash_whisperer.rb
CHANGED
@@ -39,7 +39,8 @@ class TheHashWhisperer
|
|
39
39
|
if (hash.is_a?(Array))
|
40
40
|
result << dig_array(keys, hash, target)
|
41
41
|
else
|
42
|
-
result << hash[target] if (keys.find_index(keys.first) == keys.find_index(keys.last))
|
42
|
+
result << hash[target] if (keys.find_index(keys.first) == keys.find_index(keys.last)) && (hash.is_a?(Hash))
|
43
|
+
result << hash if !(hash.is_a?(Hash))
|
43
44
|
end
|
44
45
|
|
45
46
|
return result.compact.flatten unless keys&.first && hash&.is_a?(Hash) && hash[keys.first]
|
@@ -59,6 +60,7 @@ class TheHashWhisperer
|
|
59
60
|
|
60
61
|
def dig_array(keys, hash, target)
|
61
62
|
return unless hash.is_a?(Array)
|
63
|
+
return unless hash.count > 0
|
62
64
|
result = []
|
63
65
|
keys.shift
|
64
66
|
hash.each do |value|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: the_hash_whisperer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ian Rand McKenzie
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2023-05-14 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: "Tame that wild hash to get the values you're looking for — \n without
|
14
14
|
making your eyes bleed staring at a jumbled console!"
|