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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7e96c407c46a0ad19683945d17d3994632ff201b
4
- data.tar.gz: bdfc99b0940899499998b799974a9ec9b025cd47
3
+ metadata.gz: 1d91461429967f6b098d053f1fb0c9e8d0e542ba
4
+ data.tar.gz: a3b4c545eeedc7324036a5dea852c45c8693578c
5
5
  SHA512:
6
- metadata.gz: 86f4f8e38c488b1ece54d10ba3ad5a8cd97db8d39103d99801d6b44849da75531fdc448ba5ab968068cc65751179734e3bd723b45d9c721e1d4c927ac17f7aa0
7
- data.tar.gz: 9f334bc0fd7b57c9155936a2ac5f5894291fad40ac1ca538509147ae41edc5502fb376a310d10fad8f8fde8c214f46c6c6fac9ed2b967b61ca8b3bc05db053f6
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 = {}) # rubocop:disable Metrics/MethodLength
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] = if v.is_a? Array
13
- v.map { |t| t.rename_keys(find, replace) }
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 # rubocop:enable Metrics/MethodLength
39
+ end
23
40
  end
24
41
  end
@@ -1,4 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
  module CarrotRpc
3
- VERSION = "1.1.0".freeze
3
+ VERSION = "1.2.0".freeze
4
4
  end
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.1.0
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-04 00:00:00.000000000 Z
12
+ date: 2017-08-07 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activesupport