hash_deep_search 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 +7 -0
- data/lib/hash_deep_search.rb +17 -0
- metadata +44 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: cc0b21e5faae1746947f891e397946297c706720
|
4
|
+
data.tar.gz: 26abb1808788b3e3bc2b328312a2d1e18f6b179b
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 881a52c52d9bf61d433087ee6b423819a9b9af31217b0a3b4dccde0fb980c771e948deb7b7742c77359d3e731696fbf2a168e7599ded923e47a83b5932cc4ec0
|
7
|
+
data.tar.gz: 8f6b53a4babca35047a4cf48d06ab62fa805d18e01f1440cbf86532101498a58134782dc0fa60f422444cf5f393d37c43aa83a75a11138e055532effcd8a7b4a
|
@@ -0,0 +1,17 @@
|
|
1
|
+
class HashDeepSearch
|
2
|
+
def initialize(hash)
|
3
|
+
@hash = hash
|
4
|
+
end
|
5
|
+
|
6
|
+
def search(key_to_find)
|
7
|
+
if @hash.has_key?(key_to_find)
|
8
|
+
return {key_to_find => @hash[key_to_find]}
|
9
|
+
else
|
10
|
+
@hash.keys.each do |existing_key|
|
11
|
+
next unless @hash[existing_key].is_a?(Hash)
|
12
|
+
search = HashDeepSearch.new(@hash[existing_key])
|
13
|
+
return search.search(key_to_find)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
metadata
ADDED
@@ -0,0 +1,44 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: hash_deep_search
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Manuel Korfmann
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-12-31 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description: Gem for searching hashes deeply
|
14
|
+
email: manu@korfmann.nfo
|
15
|
+
executables: []
|
16
|
+
extensions: []
|
17
|
+
extra_rdoc_files: []
|
18
|
+
files:
|
19
|
+
- lib/hash_deep_search.rb
|
20
|
+
homepage: https://github.com/ManuelArno/hash_deep_search
|
21
|
+
licenses:
|
22
|
+
- MIT
|
23
|
+
metadata: {}
|
24
|
+
post_install_message:
|
25
|
+
rdoc_options: []
|
26
|
+
require_paths:
|
27
|
+
- lib
|
28
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
29
|
+
requirements:
|
30
|
+
- - ">="
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '0'
|
33
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
34
|
+
requirements:
|
35
|
+
- - ">="
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '0'
|
38
|
+
requirements: []
|
39
|
+
rubyforge_project:
|
40
|
+
rubygems_version: 2.6.8
|
41
|
+
signing_key:
|
42
|
+
specification_version: 4
|
43
|
+
summary: Hash Deep Search
|
44
|
+
test_files: []
|