eco-helpers 2.7.23 → 2.7.24

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
2
  SHA256:
3
- metadata.gz: 1d522c29136b4722235f8dbf8349d7328ba7ebe90f77d5fecf15a03a049cc8fe
4
- data.tar.gz: b2529b04d22fcc9f013366c07a5bb7905c8d6154af97c4d235fafc1f0bf6452b
3
+ metadata.gz: 6576d3f9439855c0004110d104d82634733df41822acb362bc82cafcbf90d6ca
4
+ data.tar.gz: e0052851a9c33b54c77bcb4577874cb765e744c40ed63b7eaa5a5fd3d59632ec
5
5
  SHA512:
6
- metadata.gz: 822b1359de0c56118ed2e8e564a54c1119a2bb7597373c029cc72e3f808b3fbd94853a8eced013033613f77b0cfb0c47983e4e03e60e928e30bb6084096d9250
7
- data.tar.gz: f32a7ad2a927015c1a2a1b0642f379c1014231db7a2aea00187bf690584a738c7f6770ba361422eeecbf097f2b760c6c6ee502b8c6ca5d790354cef13bf58f26
6
+ metadata.gz: 479a0ed0a903b1f05a930673e0098912df91cb66a49b1acb99d2b7c82dd531f9bcd4704f46c0a4a84ad9f8c2e12a0469ccbc1b8760cba65fae1e7e272d6575aa
7
+ data.tar.gz: 5f626293d3de079368627f68eb5337abe64afde56f86248721ed3615a90d7e694cacde99fe78467e50fb4c24a8d19cb66670cffc14f63c08ab1b4735d9652041
data/CHANGELOG.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file.
4
4
 
5
- ## [2.7.24] - 2024-07-xx
5
+ ## [2.7.25] - 2024-07-xx
6
6
 
7
7
  ### Added
8
8
 
@@ -10,6 +10,13 @@ All notable changes to this project will be documented in this file.
10
10
 
11
11
  ### Fixed
12
12
 
13
+ ## [2.7.24] - 2024-07-30
14
+
15
+ ### Fixed
16
+
17
+ - `Eco::API::Common::People::PersonEntry#set_core`
18
+ - Exclude setting `id` (should invariably be set via back-end only)
19
+
13
20
  ## [2.7.23] - 2024-07-29
14
21
 
15
22
  ### Fixed
@@ -18,8 +25,6 @@ All notable changes to this project will be documented in this file.
18
25
 
19
26
  ## [2.7.22] - 2024-07-26
20
27
 
21
- ### Added
22
-
23
28
  ### Changed
24
29
 
25
30
  - Patch on exception: to show cause
@@ -27,8 +32,6 @@ All notable changes to this project will be documented in this file.
27
32
  - `load_json` prevent avoidable memory leaks
28
33
  - `save_json` prevent avoidable memory leaks
29
34
 
30
- ### Fixed
31
-
32
35
  ## [2.7.21] - 2024-07-13
33
36
 
34
37
  ### Added
@@ -211,7 +211,8 @@ module Eco
211
211
  # @param person [Ecoportal::API::V1::Person] the person we want to set the core values to.
212
212
  # @param exclude [String, Array<String>] core attributes that should not be set/changed to the person.
213
213
  def set_core(person, exclude: nil)
214
- scoped_attrs = @emap.core_attrs(@final_entry) - into_a(exclude)
214
+ scoped_attrs = @emap.core_attrs(@final_entry) - into_a(exclude)
215
+ scoped_attrs -= ['id']
215
216
  @final_entry.slice(*scoped_attrs).each do |attr, value|
216
217
  set_part(person, attr, value)
217
218
  rescue StandardError => e
@@ -15,12 +15,12 @@ module Eco
15
15
  def with_each(entries, people, options, append_created: true)
16
16
  @_skip_all_multiple_results = false
17
17
  people_copy = people.newFrom(people.to_a)
18
+
18
19
  entries.each_with_object([]) do |entry, scoped|
19
20
  begin
20
- unless person = people_copy.find(entry, strict: micro.strict_search?(options))
21
- person = session.new_person.tap do |person|
22
- people << person if append_created
23
- end
21
+ person = people_copy.find(entry, strict: micro.strict_search?(options))
22
+ person ||= session.new_person.tap do |pers|
23
+ people << pers if append_created
24
24
  end
25
25
  rescue Eco::API::Organization::People::MultipleSearchResults => e
26
26
  unless @_skip_all_multiple_results
@@ -29,17 +29,19 @@ module Eco
29
29
  end
30
30
  end
31
31
 
32
- if person
33
- person.entry = entry
34
- yield(entry, person) if block_given?
35
- scoped << person
36
- end
37
- end.yield_self {|all_people| people.newFrom all_people.uniq}
32
+ next unless person
33
+
34
+ person.entry = entry
35
+ yield(entry, person) if block_given?
36
+ scoped << person
37
+ end.then do |all_people|
38
+ people.newFrom all_people.uniq
39
+ end
38
40
  end
39
41
 
40
42
  private
41
43
 
42
- def _with_each_prompt_to_select_user(error, entry: nil, increase_count: true)
44
+ def _with_each_prompt_to_select_user(error, entry: nil, increase_count: true) # rubocop:disable Metrics/AbcSize
43
45
  unless error.is_a?(Eco::API::Organization::People::MultipleSearchResults)
44
46
  raise "Expecting Eco::API::Organization::People::MultipleSearchResults. Given: #{error.class}"
45
47
  end
@@ -47,7 +49,7 @@ module Eco
47
49
  @_with_each_prompts += 1 if increase_count
48
50
 
49
51
  lines = []
50
- lines << "\n(#{@_with_each_prompts}) " + error.to_s + "\n"
52
+ lines << "\n(#{@_with_each_prompts}) #{error}\n"
51
53
  lines << " #index - Select the correct person by its number index among the list above."
52
54
  lines << " (I) - Just Skip/Ignore this one. I will deal with that input entry in another launch."
53
55
  lines << " (A) - Ignore all the rest of input entries with this problem."
@@ -56,20 +58,20 @@ module Eco
56
58
 
57
59
  prompt_user("Type one option (#number/I/A/C/B):", explanation: lines.join("\n"), default: "I") do |res|
58
60
  res = res.upcase
59
- case
60
- when res.start_with?("I")
61
- logger.info "Ignoring entry... #{entry.to_s(:identify) if entry}"
61
+
62
+ if res.start_with?("I")
63
+ logger.info "Ignoring entry... #{entry&.to_s(:identify)}"
62
64
  nil
63
- when res.start_with?("A")
65
+ elsif res.start_with?("A")
64
66
  logger.info "All input entries with this same issue will be ignored for this launch"
65
67
  @_skip_all_multiple_results = true
66
68
  nil
67
- when res.start_with?("C")
69
+ elsif res.start_with?("C")
68
70
  logger.info "Creating new person...#{"for entry #{entry.to_s(:identify)}" if entry}"
69
71
  session.new_person
70
- when res.start_with?("B")
72
+ elsif res.start_with?("B")
71
73
  raise error
72
- when res && !res.empty? && (pos = res.to_i rescue nil) && (pos < error.candidates.length)
74
+ elsif res && !res.empty? && (pos = res.to_i rescue nil) && (pos < error.candidates.length) # rubocop:disable Style/RescueModifier
73
75
  error.candidate(pos).tap do |person|
74
76
  logger.info "Thanks!! You selected #{person.identify}"
75
77
  sleep(1.5)
data/lib/eco/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Eco
2
- VERSION = '2.7.23'.freeze
2
+ VERSION = '2.7.24'.freeze
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: eco-helpers
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.7.23
4
+ version: 2.7.24
5
5
  platform: ruby
6
6
  authors:
7
7
  - Oscar Segura