recursive-hash-utils 1.0.0
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/recursive-hash-utils.rb +24 -0
- metadata +47 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 51e0c58afb4093e8021daa10eae4680c5383ccba
|
4
|
+
data.tar.gz: 42a600126139d11f06a02f6233e019e678b7b6b9
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 77f40424ef627cb9b8f778e077742f9ce7fa2bec0f13866ce89869a7ec91bfcc9f8c8eb8032d0be8840075c9a7fbcdcc35df8a6147a215c8a43d496283e53fe7
|
7
|
+
data.tar.gz: a41f80dc7a96dc92a8a59476b0824af6514f4903bd3c493cc2e1abc1bcfe3e11e9449106ff9b8eea946b97fd01436615a510f261775c696c07819da919d67843
|
@@ -0,0 +1,24 @@
|
|
1
|
+
module RecursiveHashUtils
|
2
|
+
def self.convert_string_keys_to_symbols hash
|
3
|
+
s2s = lambda do |h|
|
4
|
+
if Hash === h
|
5
|
+
Hash[
|
6
|
+
h.map do |k, v|
|
7
|
+
[k.respond_to?(:to_sym) ? k.to_sym : k, s2s[v]]
|
8
|
+
end
|
9
|
+
]
|
10
|
+
elsif Array === h
|
11
|
+
hash_array = []
|
12
|
+
h.each do |val|
|
13
|
+
hash_array.push s2s[val]
|
14
|
+
end
|
15
|
+
|
16
|
+
hash_array
|
17
|
+
else
|
18
|
+
h
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
s2s[hash]
|
23
|
+
end
|
24
|
+
end
|
metadata
ADDED
@@ -0,0 +1,47 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: recursive-hash-utils
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Nick Redmond
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-01-05 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description: Provides util methods to modify Hash objects. Currently contains a single
|
14
|
+
method that converts all string keys in a Hash to symbols. Will recursively convert
|
15
|
+
string keys through hashes and hashes within arrays.
|
16
|
+
email: nicholas.john.redmond@gmail.com
|
17
|
+
executables: []
|
18
|
+
extensions: []
|
19
|
+
extra_rdoc_files: []
|
20
|
+
files:
|
21
|
+
- lib/recursive-hash-utils.rb
|
22
|
+
homepage: http://rubygems.org/gems/recursive-hash-utils
|
23
|
+
licenses:
|
24
|
+
- MIT
|
25
|
+
metadata: {}
|
26
|
+
post_install_message:
|
27
|
+
rdoc_options: []
|
28
|
+
require_paths:
|
29
|
+
- lib
|
30
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
31
|
+
requirements:
|
32
|
+
- - ">="
|
33
|
+
- !ruby/object:Gem::Version
|
34
|
+
version: '0'
|
35
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
36
|
+
requirements:
|
37
|
+
- - ">="
|
38
|
+
- !ruby/object:Gem::Version
|
39
|
+
version: '0'
|
40
|
+
requirements: []
|
41
|
+
rubyforge_project:
|
42
|
+
rubygems_version: 2.2.2
|
43
|
+
signing_key:
|
44
|
+
specification_version: 4
|
45
|
+
summary: Utils to recursively modify Hash objects.
|
46
|
+
test_files: []
|
47
|
+
has_rdoc:
|