eco-helpers 3.0.31 → 3.0.33

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.
Files changed (33) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +24 -2
  3. data/lib/eco/api/common/loaders/config/workflow/mailer.rb +13 -11
  4. data/lib/eco/api/common/loaders/use_case/cli_identify.rb +3 -0
  5. data/lib/eco/api/common/version_patches/exception.rb +10 -2
  6. data/lib/eco/api/microcases/people/fetch/with_each.rb +9 -2
  7. data/lib/eco/api/organization/people/multiple_search_results.rb +42 -36
  8. data/lib/eco/api/organization/people/similarity.rb +226 -224
  9. data/lib/eco/api/session/batch/job.rb +1 -0
  10. data/lib/eco/api/usecases/cli/dsl.rb +0 -1
  11. data/lib/eco/api/usecases/cli/option.rb +1 -1
  12. data/lib/eco/api/usecases/default_cases/create_case.rb +3 -3
  13. data/lib/eco/api/usecases/default_cases/delete_sync_case.rb +2 -2
  14. data/lib/eco/api/usecases/default_cases/delete_trans_case.rb +3 -3
  15. data/lib/eco/api/usecases/default_cases/hris_case.rb +10 -9
  16. data/lib/eco/api/usecases/default_cases/to_csv_case.rb +10 -10
  17. data/lib/eco/api/usecases/default_cases/to_csv_detailed_case.rb +50 -50
  18. data/lib/eco/api/usecases/default_cases/update_case.rb +3 -3
  19. data/lib/eco/cli/config/use_cases/active_case.rb +9 -0
  20. data/lib/eco/cli/config/use_cases/case_config.rb +27 -0
  21. data/lib/eco/cli/config/use_cases.rb +2 -15
  22. data/lib/eco/cli_default/input.rb +6 -0
  23. data/lib/eco/cli_default/usecases.rb +1 -1
  24. data/lib/eco/language/auxiliar_logger.rb +1 -1
  25. data/lib/eco/language/delegation/delegating_blank.rb +4 -16
  26. data/lib/eco/language/delegation/delegating_missing_const.rb +1 -1
  27. data/lib/eco/language/methods/call_detector.rb +4 -8
  28. data/lib/eco/language/methods/dsl_able.rb +29 -33
  29. data/lib/eco/language/methods/instance_method_helpers.rb +38 -0
  30. data/lib/eco/language/methods.rb +1 -0
  31. data/lib/eco/language.rb +1 -1
  32. data/lib/eco/version.rb +1 -1
  33. metadata +5 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: cc3166aa570a24f55a90822a79ad103419cbbd176677a5f17fe3ef8a27553cf6
4
- data.tar.gz: f3418aa7bd4e8c645b60eeb839038a03da00fb4328a6acd63bb1500dfe18cfb8
3
+ metadata.gz: c7282df5e6d33e1467e6d2ad2aa039984bad1fa4f4a4160e703f2e07f91367ec
4
+ data.tar.gz: 002bcef35564d7613bfb81c5cc9a09058c0323a4729fb0362a808f48bf64634e
5
5
  SHA512:
6
- metadata.gz: 3ca74dcfcb34cc4b252c5613fcf3bf786eb85435920fae73b3ef24e293a6ce11f96698ff0ea7f16cd57e023ce9feee613eb2f8cb44e2352b501150098a6fc0cb
7
- data.tar.gz: ad2f68c81259897a21267bbc914b6c79dda294191ce6eb9d293c080685be0bf829883b6a98c670e167602379a9af178bde80ec82f9fc0c390d48e801b7e96758
6
+ metadata.gz: d9429616ce050142667c011bb3ed1deeab286293349d344b4ad4290d87d9476c3249577f5efd73ab673315a1e95392102994bdbc20fb332233322c627f621d69
7
+ data.tar.gz: c5a88ca8ddb14ef5832e9541e03c3870ee12cbd9fa6be97cb4898fd638f7dd3cffb7b28e4d2f28298bbbb418af4d3df5aeeeeb3dcb7f32bee402907f40905dac
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
- ## [3.0.32] - 2025-04-xx
5
+ ## [3.0.34] - 2025-04-xx
6
6
 
7
7
  ### Added
8
8
 
@@ -10,10 +10,32 @@ All notable changes to this project will be documented in this file.
10
10
 
11
11
  ### Fixed
12
12
 
13
- ## [3.0.31] - 2025-04-xx
13
+ ## [3.0.33] - 2025-04-08
14
14
 
15
15
  ### Added
16
16
 
17
+ - `Mailer` to include `:general` channel messages.
18
+ - And simplified code
19
+ - `CliDefault::Input` to log in `:general` channel what files have beens scoped.
20
+
21
+ ### Changed
22
+
23
+ - **Improved** recursive `cause` on repeated error.
24
+ - `AuxiliarLogger` to use `:debug` as default, when `:general` channel is used without specifying an actual log level.
25
+
26
+ ## [3.0.32] - 2025-04-08
27
+
28
+ ### Added
29
+
30
+ - `MicroCase#with_each` added option to pick up the first user.
31
+
32
+ ### Fixed
33
+
34
+ - `Eco::API::Organization::People`
35
+ - `MultipleSearchResults` and `Similarity` where in a different namespace.
36
+
37
+ ## [3.0.31] - 2025-04-04
38
+
17
39
  ### Changed
18
40
 
19
41
  - upgraded `ecoportal-api-gem`
@@ -22,19 +22,14 @@ class Eco::API::Common::Loaders::Workflow::Mailer < Eco::API::Common::Loaders::W
22
22
  next unless some_update_case?(io) || maybe_error_pages_or_tree_updates?(io)
23
23
 
24
24
  subject = base_subject
25
+ subject = "#{subject} & Errors" if session.job_groups.errors?
26
+ subject = "#{subject} - Exception!" if error?
25
27
 
26
- if session.job_groups.empty? && error?
27
- subject = "#{subject} - Exception!"
28
- session.mail(subject: subject, body: errors_n_warnings(io))
29
- else
30
- subject = "#{subject} & Errors" if session.job_groups.errors?
31
- subject = "#{subject} - Exception!" if error?
28
+ body = general_messages(io)
29
+ body << "\n#{session.summary}" unless session.job_groups.empty? && error?
30
+ body << "\n#{errors_n_warnings(io)}"
32
31
 
33
- msg = "#{session.summary}\n"
34
- msg += errors_n_warnings(io)
35
-
36
- session.mail(subject: subject, body: msg) unless msg.strip.empty?
37
- end
32
+ session.mail(subject: subject, body: body) unless body.strip.empty?
38
33
  end
39
34
  end
40
35
 
@@ -66,6 +61,13 @@ class Eco::API::Common::Loaders::Workflow::Mailer < Eco::API::Common::Loaders::W
66
61
  some_other_case?(io) && error?
67
62
  end
68
63
 
64
+ def general_messages(io)
65
+ gen_msg = io.logger.cache.logs(level: %i[general])
66
+ return if gen_msg.empty?
67
+
68
+ "GENERAL MESSAGES:\n#{gen_msg.join}\n"
69
+ end
70
+
69
71
  def errors_n_warnings(io)
70
72
  [error_message, log_err_n_warn(io)].join("\n")
71
73
  end
@@ -4,6 +4,9 @@ class Eco::API::Common::Loaders::UseCase
4
4
  cli&.apply!
5
5
  end
6
6
 
7
+ # It uses the `cli_class` to install the Cli. If not given, it tries
8
+ # to identify if there's a `Case::Cli` constant defined that it is a Cli class.
9
+ # @todo check if `@cli` should really be fixed to a value (currently not).
7
10
  def cli(cli_class = nil)
8
11
  if cli_class.is_a?(Class)
9
12
  msg = 'cli_class should inherit from Eco::API::UseCases::Cli'
@@ -1,5 +1,10 @@
1
1
  class ::Exception
2
- def patch_full_message(trace_count: -1)
2
+ def patch_full_message(trace_count: -1, cause_levels: 3)
3
+ return unless cause_levels.positive?
4
+
5
+ cause_levels -= 1
6
+ trace_count = 3 if trace_count.negative? || trace_count > 3
7
+
3
8
  tracing = backtrace || []
4
9
  first_ln = tracing[0]
5
10
  tracing = tracing[1..trace_count]
@@ -14,7 +19,10 @@ class ::Exception
14
19
 
15
20
  unless cause.nil?
16
21
  msg << "\nCAUSE:"
17
- msg << cause.patch_full_message(trace_count: trace_count)
22
+ msg << cause.patch_full_message(
23
+ trace_count: trace_count,
24
+ cause_levels: cause_levels
25
+ )
18
26
  end
19
27
 
20
28
  msg.join("\n")
@@ -45,7 +45,7 @@ module Eco
45
45
 
46
46
  private
47
47
 
48
- def _with_each_prompt_to_select_user(error, entry: nil, increase_count: true) # rubocop:disable Metrics/AbcSize
48
+ def _with_each_prompt_to_select_user(error, entry: nil, increase_count: true) # rubocop:disable Metrics/AbcSize, Metrics/MethodLength
49
49
  unless error.is_a?(Eco::API::Organization::People::MultipleSearchResults)
50
50
  raise "Expecting Eco::API::Organization::People::MultipleSearchResults. Given: #{error.class}"
51
51
  end
@@ -57,11 +57,12 @@ module Eco
57
57
  lines << "\n(#{@_with_each_prompts}) #{error}\n"
58
58
  lines << ' #index - Select the correct person by its number index among the list above.'
59
59
  lines << ' (I) - Just Skip/Ignore this one. I will deal with that input entry in another launch.'
60
+ lines << ' (U) - The first person with a user account.'
60
61
  lines << ' (A) - Ignore all the rest of input entries with this problem.'
61
62
  lines << ' (C) - Create a new person.'
62
63
  lines << ' (B) - Just break this script. I need to change the input file :/'
63
64
 
64
- prompt_user('Type one option (#number/I/A/C/B):', explanation: lines.join("\n"), default: 'I') do |res|
65
+ prompt_user('Type one option (#number/I/U/A/C/B):', explanation: lines.join("\n"), default: 'I') do |res|
65
66
  res = res.upcase
66
67
 
67
68
  if res.start_with?('I')
@@ -83,6 +84,12 @@ module Eco
83
84
  session.new_person
84
85
  elsif res.start_with?('B')
85
86
  raise error
87
+ elsif res.start_with?('U')
88
+ error.first_user.tap do |person|
89
+ next unless person
90
+
91
+ log(:info) { "(first user) You selected #{person.identify}" }
92
+ end
86
93
  elsif res && !res.empty? && (pos = res.to_i rescue nil) && (pos < error.candidates.length) # rubocop:disable Style/RescueModifier
87
94
  error.candidate(pos).tap do |person|
88
95
  log(:info) { "Thanks!! You selected #{person.identify}" }
@@ -1,46 +1,52 @@
1
- module API
2
- module Organization
3
- class People
4
- # Error class that allows to handle cases where multiple people were found for the same criterion.
5
- # @note its main purpose to prevent the creation of duplicates or override information between different people.
6
- class MultipleSearchResults < StandardError
7
- attr_reader :candidates, :property
8
-
9
- # @param msg [String] the basic message error.
10
- # @param candiates [Array<Person>] the people that match the same search criterion.
11
- # @param property [String] the property of the person model that triggered the error (base of the search criterion).
12
- def initialize(msg, candidates: [], property: 'email')
13
- @candidates = candidates
14
- @property = property
15
- super("#{msg} #{candidates_summary}")
16
- end
1
+ module Eco
2
+ module API
3
+ module Organization
4
+ class People
5
+ # Error class that allows to handle cases where multiple people were found for the same criterion.
6
+ # @note its main purpose to prevent the creation of duplicates or override information between different people.
7
+ class MultipleSearchResults < StandardError
8
+ attr_reader :candidates, :property
17
9
 
18
- # @param with_index [Boolean] to add an index to each candidate description.
19
- # @return [Array<String>] the `candidates` identified
20
- def identify_candidates(with_index: false)
21
- candidates.map.each_with_index do |person, i|
22
- index = with_index ? "#{i}. " : ''
10
+ # @param msg [String] the basic message error.
11
+ # @param candiates [Array<Person>] the people that match the same search criterion.
12
+ # @param property [String] the property of the person model that triggered the error (base of the search criterion).
13
+ def initialize(msg, candidates: [], property: 'email')
14
+ @candidates = candidates
15
+ @property = property
16
+ super("#{msg} #{candidates_summary}")
17
+ end
23
18
 
24
- msg = '(no account)'
25
- if person.account
26
- msg = '(user)'
27
- msg = '(new user)' if person.account_added?
28
- end
19
+ def first_user
20
+ candidates.detect(&:account)
21
+ end
22
+
23
+ # @param with_index [Boolean] to add an index to each candidate description.
24
+ # @return [Array<String>] the `candidates` identified
25
+ def identify_candidates(with_index: false)
26
+ candidates.map.each_with_index do |person, i|
27
+ index = with_index ? "#{i}. " : ''
28
+
29
+ msg = '(no account)'
30
+ if person.account
31
+ msg = '(user)'
32
+ msg = '(new user)' if person.account_added?
33
+ end
29
34
 
30
- "#{index}#{msg} #{person.identify}"
35
+ "#{index}#{msg} #{person.identify}"
36
+ end
31
37
  end
32
- end
33
38
 
34
- # @return [Person] the `candidate` in the `index` position
35
- def candidate(index)
36
- candidates[index]
37
- end
39
+ # @return [Person] the `candidate` in the `index` position
40
+ def candidate(index)
41
+ candidates[index]
42
+ end
38
43
 
39
- private
44
+ private
40
45
 
41
- def candidates_summary
42
- lines = ["The following people have the same '#{property}':"]
43
- lines.concat(identify_candidates(with_index: true)).join("\n ")
46
+ def candidates_summary
47
+ lines = ["The following people have the same '#{property}':"]
48
+ lines.concat(identify_candidates(with_index: true)).join("\n ")
49
+ end
44
50
  end
45
51
  end
46
52
  end