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.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/the_hash_whisperer.rb +3 -1
  3. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 43d77e1352362539179673141aad2e31018eb454fc2913842c7d7fff33ae4f84
4
- data.tar.gz: 1adb4aa3f60ee7a2977f18c4370b2c3990b582efa416cba653442d27f7d807aa
3
+ metadata.gz: 83bed796abff012203695cf253e058ffea3d2bfa7e3bb70a59646fc7abd35152
4
+ data.tar.gz: fb41a6613634d8cc9785101910448dbb179fb35e2641ef62214e7c8da8623f58
5
5
  SHA512:
6
- metadata.gz: 0ebe11c6b004979069da6e6a9d01503f576edb01585bab3794ced36ab78e815efb551fc62780d6ddab2b2f0c1e480d27f176e90615747a98f8ac908639e31155
7
- data.tar.gz: de9ef18ede3a0bb1412c741a830cfbcbf5b45c8bd42c17f5253822f0c7008601e59762b2528b2c2e31249abd921ff86db520fd7c73fd4118bc1de2d11f34d2f6
6
+ metadata.gz: fdd125842a8d660b9bfd6843680f6c00b6a179b8e5c819e8bfb11adc5f8bf6af7af2d647863e78b27470d2073c9614d67591ae0f2f541ba352eff1bbeb92bad0
7
+ data.tar.gz: 025c9d1c0bd1e8ff20bb10054fb1db8906a3230b6060a4ed175c295ddafd84d0ddbe933f4fdb0cdc7c2a9c902ea06742f0125cdf97c8c86fe3b3dd34f58a4ed3
@@ -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.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: 2022-09-21 00:00:00.000000000 Z
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!"