attr-gather 1.2.1 → 1.3.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
  SHA256:
3
- metadata.gz: 56fa2344f15f389295db52f8201720d91bae7114d5d68472208d5509fe40d35d
4
- data.tar.gz: cce04b8b3ebe30523f0b4b5528f2531d5607e1905e6869f21076ac7eeac39e34
3
+ metadata.gz: edfd2d7479248348551d31676b45459f6f8279f6ca5fdf6ed00540c791de86bd
4
+ data.tar.gz: 977ac39f355ded8101507de998a221354ba357bad66528f9efbbb50200d4d731
5
5
  SHA512:
6
- metadata.gz: dad243cf700400e4bab5abb9134704870885c711a6a4c4eedf185860af66485493f16d2a2fda99b103e1ab7b5238c244e16a73a7b1264b9f59cee6f42bbdf2b7
7
- data.tar.gz: 46441ed69c96018c33c4676e3e48b3b06bf39de8aaa2f16c20fdda026375bd66330064c11ac8ea4f7499b0038c98309a3f958ea532ab6da1476dad2e5e070de1
6
+ metadata.gz: 958601e4741c30c6707ee6808fb89a258dfa10bab373f623d63fed29faef5eaf0d54d8fecfba4e9949bd16afb7d23bd84aca80aa2d485243de84076e2087284a
7
+ data.tar.gz: 11d1ae7d926743a202413647e1fe0f75e3c47966c9444c83a25e706ab8b923fa37ea2cda565042634d0cf6abc900be5fa2e1d3b47c436e6efc950a5d6f3d8fde
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- attr-gather (1.2.1)
4
+ attr-gather (1.3.0)
5
5
  dry-container (~> 0.7)
6
6
 
7
7
  GEM
data/README.md CHANGED
@@ -1,7 +1,6 @@
1
1
  # attr-gather
2
2
 
3
3
  ![Actions Status](https://github.com/ianks/attr-gather/workflows/Build%20+%20Test%20+%20Lint/badge.svg)
4
- [![Maintainability](https://api.codeclimate.com/v1/badges/b825a3bc37ad6a76e005/maintainability)](https://codeclimate.com/github/ianks/attr-gather/maintainability)
5
4
 
6
5
  A gem for creating workflows that "enhance" entities with extra attributes. At a high level, [attr-gather](https://github.com/ianks/attr-gather) provides a process to fetch information from many data sources (such as third party APIs, legacy databases, etc.) in a fully parallelized fashion.
7
6
 
@@ -12,25 +12,28 @@ module Attr
12
12
  # Initialize a new DeepMerge aggregator
13
13
  #
14
14
  # @param reverse [Boolean] deep merge results in reverse order
15
- # @param merge_input [Boolean] merge the result with the initial input
16
15
  #
17
16
  # @api private
18
- def initialize(reverse: false, merge_input: true, **)
17
+ def initialize(reverse: false, **)
19
18
  @reverse = reverse
20
- @merge_input = merge_input
21
19
  super
22
20
  end
23
21
 
24
22
  def call(input, execution_results)
25
23
  execution_results = execution_results.reverse_each if reverse?
24
+ initial = unwrap_initial_input(input)
26
25
 
27
- execution_results.reduce(@merge_input ? input : EMPTY_HASH) do |memo, res|
26
+ execution_results.reduce(initial) do |memo, res|
28
27
  deep_merge(memo, unwrap_result(res))
29
28
  end
30
29
  end
31
30
 
32
31
  private
33
32
 
33
+ def unwrap_initial_input(input)
34
+ input
35
+ end
36
+
34
37
  def reverse?
35
38
  @reverse
36
39
  end
@@ -12,19 +12,17 @@ module Attr
12
12
  # Initialize a new DeepMerge aggregator
13
13
  #
14
14
  # @param reverse [Boolean] merge results in reverse order
15
- # @param merge_input [Boolean] merge the result with the initial input
16
15
  #
17
16
  # @api private
18
- def initialize(reverse: false, merge_input: true, **)
17
+ def initialize(reverse: false, **)
19
18
  @reverse = reverse
20
- @merge_input = merge_input
21
19
  super
22
20
  end
23
21
 
24
22
  def call(input, execution_results)
25
23
  execution_results = execution_results.reverse_each if reverse?
26
24
 
27
- execution_results.reduce(@merge_input ? input : EMPTY_HASH) do |memo, res|
25
+ execution_results.reduce(input) do |memo, res|
28
26
  memo.merge(unwrap_result(res))
29
27
  end
30
28
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Attr
4
4
  module Gather
5
- VERSION = '1.2.1'
5
+ VERSION = '1.3.0'
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: attr-gather
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.1
4
+ version: 1.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ian Ker-Seymer
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-05-28 00:00:00.000000000 Z
11
+ date: 2020-12-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -127,7 +127,7 @@ licenses:
127
127
  metadata:
128
128
  homepage_uri: https://github.com/ianks/attr-gather
129
129
  source_code_uri: https://github.com/ianks/attr-gather
130
- post_install_message:
130
+ post_install_message:
131
131
  rdoc_options: []
132
132
  require_paths:
133
133
  - lib
@@ -143,7 +143,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
143
143
  version: '0'
144
144
  requirements: []
145
145
  rubygems_version: 3.0.3
146
- signing_key:
146
+ signing_key:
147
147
  specification_version: 4
148
148
  summary: Write a short summary, because RubyGems requires one.
149
149
  test_files: []