hash_remapper 0.2.0 → 0.2.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/hash_remapper.gemspec +2 -0
- data/lib/hash_remapper.rb +5 -2
- metadata +3 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c3929c1154c630edcdf0237da51662e03efddb6f222d5b67afb98e6a80313dc9
|
4
|
+
data.tar.gz: 803ac91bfd04de4db2fbd46754d23e827d06c18906c508a1aca524e291aa936e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 718a7fa4670375daf3c8260dc2b8bd48050f51b3e1ad022c0a8112e98d8f72f2ff3d2b2ed52627b88af98b44f13b0429dddcea7c2befa7fb767c84ccb944b2dd
|
7
|
+
data.tar.gz: b0715035503568d32c7213891973a39342924da1f5fd74d35abdad776227c5460468a461d3ba60477eeb3a3be7b617bd291e9114e95b3ba4509eb713bd3c19d1
|
data/hash_remapper.gemspec
CHANGED
data/lib/hash_remapper.rb
CHANGED
@@ -6,7 +6,7 @@ require 'hash_digger'
|
|
6
6
|
# Utility class to map original Hash keys to the new ones
|
7
7
|
class HashRemapper
|
8
8
|
# Current Library Version
|
9
|
-
VERSION = '0.2.
|
9
|
+
VERSION = '0.2.1'
|
10
10
|
|
11
11
|
class << self
|
12
12
|
# Remaps `data` Hash by renaming keys, creating new ones and
|
@@ -66,13 +66,16 @@ class HashRemapper
|
|
66
66
|
# (if the mapping value is enumerable)
|
67
67
|
# @see https://github.com/smileart/hash_digger
|
68
68
|
#
|
69
|
-
# @param [
|
69
|
+
# @param [Array] to the target key to map to ([new_key, digging_path, strict_flag])
|
70
70
|
# @param [Hash] data the whole original Hash to use as the digging target
|
71
71
|
#
|
72
72
|
# @return [Array(Object,Object)] key and its value to put to the resulting Hash
|
73
73
|
def try_digging(to, data)
|
74
74
|
return unless to.respond_to?(:each)
|
75
75
|
|
76
|
+
# v0.1.0 backward compartability layer
|
77
|
+
return [to.first, data.dig(*to.last)] if to.fetch(1).kind_of?(Array)
|
78
|
+
|
76
79
|
# @see https://github.com/DamirSvrtan/fasterer — fetch_with_argument_vs_block
|
77
80
|
[
|
78
81
|
to.fetch(0),
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hash_remapper
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Serge Bedzhyk
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-06-
|
11
|
+
date: 2019-06-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -204,8 +204,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
204
204
|
- !ruby/object:Gem::Version
|
205
205
|
version: '0'
|
206
206
|
requirements: []
|
207
|
-
|
208
|
-
rubygems_version: 2.7.8
|
207
|
+
rubygems_version: 3.0.1
|
209
208
|
signing_key:
|
210
209
|
specification_version: 4
|
211
210
|
summary: A little lib which maps original keys to the new ones
|