carrot_rpc 1.1.0 → 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +8 -0
- data/lib/carrot_rpc/hash_extensions.rb +22 -5
- data/lib/carrot_rpc/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1d91461429967f6b098d053f1fb0c9e8d0e542ba
|
4
|
+
data.tar.gz: a3b4c545eeedc7324036a5dea852c45c8693578c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6d1c5d91ba7a8d38d79c07a6cdfa199e255e94acaae5de79c21df909bd7c5ec0bf8ec395280582e164506f0401d0c93d06f0319fc935f7a2340e5c244a10ae68
|
7
|
+
data.tar.gz: f3d13520bb85c81889ac8dc470fc07c93f96e21273ddc444861b958969c37ef4a83cc7ecbfd0a7207ff47bae058a947878ca14c2dead5aeefc02d310900716d7
|
data/CHANGELOG.md
CHANGED
@@ -56,6 +56,14 @@
|
|
56
56
|
# Changelog
|
57
57
|
All significant changes in the project are documented here.
|
58
58
|
|
59
|
+
## v1.2.0
|
60
|
+
|
61
|
+
### Enhancements
|
62
|
+
* [#57](https://github.com/C-S-D/carrot_rpc/pull/57) - Regression test to prevent rename_keys being called on `String` - [@KronicDeth](https://gitub.com/KronicDeth)
|
63
|
+
|
64
|
+
### Bug Fixes
|
65
|
+
* [#57](https://github.com/C-S-D/carrot_rpc/pull/57) - Only rename key in values that are `Array`s or `Hash`es. - [@KronicDeth](https://gitub.com/KronicDeth)
|
66
|
+
|
59
67
|
## v1.1.0
|
60
68
|
|
61
69
|
### Enhancements
|
@@ -1,17 +1,34 @@
|
|
1
1
|
# Refine the Hash class with new methods and functionality.
|
2
2
|
module CarrotRpc::HashExtensions
|
3
|
+
refine Array do
|
4
|
+
# Utility method to rename keys in a hash nested under array
|
5
|
+
#
|
6
|
+
# @param [String] find the text to look for in a keys
|
7
|
+
# @param [String] replace the text to replace the found text
|
8
|
+
# @return [Array] a new Array
|
9
|
+
def rename_keys(find, replace)
|
10
|
+
map { |element|
|
11
|
+
case element
|
12
|
+
when Array, Hash
|
13
|
+
element.rename_keys(find, replace)
|
14
|
+
else
|
15
|
+
element
|
16
|
+
end
|
17
|
+
}
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
3
21
|
refine Hash do
|
4
22
|
# Utility method to rename keys in a hash
|
5
23
|
# @param [String] find the text to look for in a keys
|
6
24
|
# @param [String] replace the text to replace the found text
|
7
25
|
# @return [Hash] a new hash
|
8
|
-
def rename_keys(find, replace, new_hash = {})
|
26
|
+
def rename_keys(find, replace, new_hash = {})
|
9
27
|
each do |k, v|
|
10
28
|
new_key = k.to_s.gsub(find, replace)
|
11
29
|
|
12
|
-
new_hash[new_key] =
|
13
|
-
|
14
|
-
elsif v.is_a? Hash
|
30
|
+
new_hash[new_key] = case v
|
31
|
+
when Array, Hash
|
15
32
|
v.rename_keys(find, replace)
|
16
33
|
else
|
17
34
|
v
|
@@ -19,6 +36,6 @@ module CarrotRpc::HashExtensions
|
|
19
36
|
end
|
20
37
|
|
21
38
|
new_hash
|
22
|
-
end
|
39
|
+
end
|
23
40
|
end
|
24
41
|
end
|
data/lib/carrot_rpc/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: carrot_rpc
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Scott Hamilton
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2017-08-
|
12
|
+
date: 2017-08-07 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activesupport
|