hanami-utils 1.1.0 → 1.1.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: c6d30f140bf19e5b5aeb6efef73e952d2ec1410e
4
- data.tar.gz: 497a74c90d376ffd622aa6a42c10e1a6a0c0b8d4
2
+ SHA256:
3
+ metadata.gz: 6fe9e18d01dfa9fc028b6844007dfcb410a0a03976bc84602ca1961527b9ed10
4
+ data.tar.gz: de05ca0f54e2f88eb25f095c110e97f6655e3598b39a107b57931615589a67e3
5
5
  SHA512:
6
- metadata.gz: 877777f3b3e4ec23f8316a9bbe1bdc497b02a1a500550e53456c649107be24ce14adc99c10e83d5e18c1cf8deeb402137b508066573fb44056c0543ff39937dd
7
- data.tar.gz: 741334c7eac873fd2041b27309d11d0762554592c8badbe3948260804558f707348697037f31901e56bfe96262414d85981521cdbce2128d6bce7775579ded32
6
+ metadata.gz: e1279e5ab714af6ac575371da4f952349d309c7e6a804ef1aaf24f44944678dc899d15d8f9cc1e46fda6c51da6cb698d70283da61d8528aa56b8fcceebcc0516
7
+ data.tar.gz: 7a1215ecec9a8bc03f4b474620575f471f254c487c87f6d9415933107d1d3c598ee8815f4086e90b84a0099e1d051519eedc36ea9d313bd97730f29263fee146
data/CHANGELOG.md CHANGED
@@ -1,6 +1,13 @@
1
1
  # Hanami::Utils
2
2
  Ruby core extentions and class utilities for Hanami
3
3
 
4
+ ## v1.1.1 - 2017-11-22
5
+ ### Added
6
+ - [Luca Guidi] Introduce `Utils::Hash.deep_stringify` to recursively stringify a hash
7
+
8
+ ### Fixed
9
+ - [Yuta Tokitake] Ensure `Interactor#call` to accept non-keyword arguments
10
+
4
11
  ## v1.1.0 - 2017-10-25
5
12
  ### Added
6
13
  - [Luca Guidi] Introduce `Utils::Hash.deep_serialize` to recursively serialize input into `::Hash`
@@ -351,18 +351,18 @@ module Hanami
351
351
  # end
352
352
  #
353
353
  # Signup.new.call # => NoMethodError
354
- def call(*args, **kwargs)
354
+ def call(*args)
355
355
  @__result = ::Hanami::Interactor::Result.new
356
- _call(*args, **kwargs) { super }
356
+ _call(*args) { super }
357
357
  end
358
358
 
359
359
  private
360
360
 
361
361
  # @api private
362
362
  # @since 1.1.0
363
- def _call(*args, **kwargs)
363
+ def _call(*args)
364
364
  catch :fail do
365
- validate!(*args, **kwargs)
365
+ validate!(*args)
366
366
  yield
367
367
  end
368
368
 
@@ -370,8 +370,8 @@ module Hanami
370
370
  end
371
371
 
372
372
  # @since 1.1.0
373
- def validate!(*args, **kwargs)
374
- fail! unless valid?(*args, **kwargs)
373
+ def validate!(*args)
374
+ fail! unless valid?(*args)
375
375
  end
376
376
  end
377
377
 
@@ -89,6 +89,38 @@ module Hanami
89
89
  self[:stringify_keys].call(input)
90
90
  end
91
91
 
92
+ # Deeply stringify the given hash
93
+ #
94
+ # @param input [::Hash] the input
95
+ #
96
+ # @return [::Hash] the deep stringified hash
97
+ #
98
+ # @since 1.1.1
99
+ #
100
+ # @example Basic Usage
101
+ # require "hanami/utils/hash"
102
+ #
103
+ # hash = Hanami::Utils::Hash.deep_stringify(foo: "bar", baz: {a: 1})
104
+ # # => {"foo"=>"bar", "baz"=>{"a"=>1}}
105
+ #
106
+ # hash.class
107
+ # # => Hash
108
+ def self.deep_stringify(input) # rubocop:disable Metrics/MethodLength
109
+ input.each_with_object({}) do |(key, value), output|
110
+ output[key.to_s] =
111
+ case value
112
+ when ::Hash
113
+ deep_stringify(value)
114
+ when Array
115
+ value.map do |item|
116
+ item.is_a?(::Hash) ? deep_stringify(item) : item
117
+ end
118
+ else
119
+ value
120
+ end
121
+ end
122
+ end
123
+
92
124
  # Deep duplicate hash values
93
125
  #
94
126
  # The output of this function is a shallow duplicate of the input.
@@ -3,6 +3,6 @@ module Hanami
3
3
  # Defines the version
4
4
  #
5
5
  # @since 0.1.0
6
- VERSION = '1.1.0'.freeze
6
+ VERSION = '1.1.1'.freeze
7
7
  end
8
8
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hanami-utils
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Luca Guidi
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-10-25 00:00:00.000000000 Z
11
+ date: 2017-11-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: transproc
@@ -134,7 +134,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
134
134
  version: '0'
135
135
  requirements: []
136
136
  rubyforge_project:
137
- rubygems_version: 2.6.13
137
+ rubygems_version: 2.7.1
138
138
  signing_key:
139
139
  specification_version: 4
140
140
  summary: Ruby core extentions and Hanami utilities