eco-helpers 3.2.1 → 3.2.3

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 (57) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +1 -1
  3. data/CHANGELOG.md +36 -1
  4. data/eco-helpers.gemspec +3 -3
  5. data/lib/eco/api/common/loaders/config/workflow/mailer.rb +1 -0
  6. data/lib/eco/api/common/people/person_entry.rb +6 -1
  7. data/lib/eco/api/common/people/person_parser.rb +1 -0
  8. data/lib/eco/api/microcases/people/manage/cache.rb +21 -16
  9. data/lib/eco/api/microcases/people/manage/filename.rb +29 -0
  10. data/lib/eco/api/microcases/people/manage/load.rb +6 -48
  11. data/lib/eco/api/microcases/people/manage/load_cache.rb +29 -0
  12. data/lib/eco/api/microcases/people/manage/refresh.rb +5 -3
  13. data/lib/eco/api/microcases/people/manage.rb +4 -0
  14. data/lib/eco/api/organization/tag_tree.rb +11 -4
  15. data/lib/eco/api/session/batch/searcher.rb +3 -3
  16. data/lib/eco/api/session/config/people.rb +23 -20
  17. data/lib/eco/api/usecases/default/locations/tagtree_upload_case.rb +20 -2
  18. data/lib/eco/api/usecases/graphql/helpers/location/base/tree_tracking.rb +14 -7
  19. data/lib/eco/api/usecases/graphql/helpers/location/base.rb +1 -1
  20. data/lib/eco/api/usecases/graphql/helpers/location/command/diff/as_update.rb +0 -1
  21. data/lib/eco/api/usecases/graphql/helpers/location/command/diffs/stages/diff_sortable/for_archive.rb +0 -1
  22. data/lib/eco/api/usecases/graphql/helpers/location/command/end_points/optimizations.rb +64 -0
  23. data/lib/eco/api/usecases/graphql/helpers/location/command/end_points.rb +96 -0
  24. data/lib/eco/api/usecases/graphql/helpers/location/command/input_unit_response.rb +69 -0
  25. data/lib/eco/api/usecases/graphql/helpers/location/command/result.rb +11 -10
  26. data/lib/eco/api/usecases/graphql/helpers/location/command/results.rb +120 -63
  27. data/lib/eco/api/usecases/graphql/helpers/location/command.rb +26 -26
  28. data/lib/eco/api/usecases/graphql/samples/location/command/dsl.rb +195 -37
  29. data/lib/eco/api/usecases/graphql/samples/location/command/results.rb +45 -13
  30. data/lib/eco/api/usecases/graphql/samples/location/command/service/tree_update.rb +0 -51
  31. data/lib/eco/api/usecases/graphql/samples/location/command/track_changed_ids.rb +6 -14
  32. data/lib/eco/api/usecases/graphql/samples/location/command.rb +1 -1
  33. data/lib/eco/api/usecases/graphql/samples/location/service/tree_diff/convertible/inputable.rb +4 -1
  34. data/lib/eco/api/usecases/graphql/samples/location/service/tree_diff.rb +6 -0
  35. data/lib/eco/api/usecases/graphql/samples/location/service/tree_to_list/converter/input.rb +1 -0
  36. data/lib/eco/api/usecases/lib/error_handling.rb +1 -1
  37. data/lib/eco/api/usecases/ooze_samples/helpers/creatable.rb +1 -0
  38. data/lib/eco/api/usecases/ooze_samples/helpers/rescuable.rb +1 -0
  39. data/lib/eco/api/usecases/samples/drivers/cli/sftp_cli.rb +1 -1
  40. data/lib/eco/api/usecases/samples/drivers/sftp_sample.rb +4 -1
  41. data/lib/eco/api/usecases/samples/drivers/url_pull_sample.rb +12 -9
  42. data/lib/eco/api/usecases/samples/people/filters/cli/require_id_cli.rb +5 -0
  43. data/lib/eco/api/usecases/samples/people/filters/cli/require_min_entries_cli.rb +5 -0
  44. data/lib/eco/api/usecases/samples/people/filters/require_id_sample.rb +61 -0
  45. data/lib/eco/api/usecases/samples/people/filters/require_min_entries_sample.rb +20 -0
  46. data/lib/eco/api/usecases/samples/people/filters.rb +7 -0
  47. data/lib/eco/api/usecases/samples/people.rb +12 -0
  48. data/lib/eco/api/usecases/samples.rb +1 -0
  49. data/lib/eco/cli_default/options.rb +5 -0
  50. data/lib/eco/data/hashes/array_diff.rb +14 -4
  51. data/lib/eco/data/locations/node_base/csv_convert.rb +9 -1
  52. data/lib/eco/data/locations/node_base/tag_validations.rb +2 -2
  53. data/lib/eco/data/locations/node_diff/nodes_diff/diffs_tree.rb +10 -3
  54. data/lib/eco/data/locations/node_diff/nodes_diff.rb +6 -0
  55. data/lib/eco/version.rb +1 -1
  56. metadata +23 -13
  57. data/lib/eco/api/usecases/graphql/helpers/location/command/optimizations.rb +0 -84
@@ -1,9 +1,51 @@
1
1
  class Eco::API::UseCases::GraphQL::Samples::Location
2
2
  module Command::DSL
3
+ include Eco::API::UseCases::GraphQL::Samples::Location::Service::TreeDiff
3
4
  include Eco::API::UseCases::GraphQL::Helpers::Location::Command
4
5
  include Eco::API::UseCases::GraphQL::Samples::Location::Command::TrackChangedIds
5
6
  include Eco::API::UseCases::GraphQL::Samples::Location::Command::Results
6
7
 
8
+ def print_diff_details?
9
+ false
10
+ end
11
+
12
+ # Default tree tacking behaviour
13
+ # @note
14
+ # 1. This aims to optimize the time run
15
+ # 2. Based on update stage, there are differentiated tracking needs
16
+ # @note Available options are:
17
+ # - :per_request -> on each request
18
+ # - :per_batch -> at the end of each batch / stage (on last page)
19
+ # - :once -> only when the script starts to run
20
+ # @return [Symbol] the tracking mode
21
+ def batch_tree_track_mode(stage)
22
+ case stage
23
+ when :unarchive, :archive
24
+ :once
25
+ when :id, :id_name
26
+ :per_request
27
+ when :insert, :move
28
+ :per_batch
29
+ else
30
+ default_tree_tracking_mode
31
+ end
32
+ end
33
+
34
+ # With given the commands, it generates the input of the endpoint mutation.
35
+ # @param commands [Array<Hash>]
36
+ def input(commands, force_continue: force_continue?)
37
+ return unless (commands || []).any?
38
+
39
+ results.draft ||= create_draft(current_tree.id).draft
40
+
41
+ {
42
+ clientMutationId: '',
43
+ id: results.draft_id,
44
+ commands: commands
45
+ }
46
+ end
47
+
48
+ # @note this method should be overriden/re-implemented
7
49
  # @example of implementation:
8
50
  # def inputs(command_types, force_continue: force_continue?)
9
51
  # {}.tap do |sequence|
@@ -16,14 +58,27 @@ class Eco::API::UseCases::GraphQL::Samples::Location
16
58
  # end
17
59
  # end
18
60
  # end
19
- def inputs(*_args, force_continue: force_continue?, **_kargs, &_block) # rubocop:disable Lint/UnusedMethodArgument
20
- msg = "You should implement this method in your child class.\n"
21
- msg << 'Which should yield the input Hash and the stage or descriptor.'
22
- raise Eco::API::UseCases::GraphQL::Base::NotImplementedMethod, msg
61
+ def inputs(nodes_diff = comparer, force_continue: force_continue?)
62
+ {}.tap do |sequence|
63
+ unless nodes_diff && nodes_diff.respond_to?(:commands)
64
+ msg = "You should implement this method in your child class.\n"
65
+ msg << "Which should yield the input Hash and the stage or descriptor.\n"
66
+ msg << "Or you should provide the `nodes_diff` object."
67
+ raise Eco::API::UseCases::GraphQL::Base::NotImplementedMethod, msg
68
+ end
69
+
70
+ nodes_diff.commands do |comms, stage|
71
+ sequence[stage] = input(comms, force_continue: force_continue)
72
+ end
73
+ end.tap do |sequence|
74
+ sequence.each do |stage, input|
75
+ yield(input, stage) if block_given?
76
+ end
77
+ end
23
78
  end
24
79
 
25
- # Main processor
26
- def process # rubocop:disable Metrics/AbcSize
80
+ # MAIN PROCESSOR
81
+ def process
27
82
  self.error = false
28
83
 
29
84
  with_error_handling do
@@ -32,49 +87,152 @@ class Eco::API::UseCases::GraphQL::Samples::Location
32
87
  # this may trigger a backup of the tagtree
33
88
  self.current_tree ||= live_tree
34
89
 
35
- inputs(force_continue: force_continue?) do |input, stage|
36
- results[stage] ||= []
37
-
38
- track_mode = batch_tree_track_mode(stage)
39
-
40
- # yields the result of each batch
41
- sliced_batches(input, desc: stage, track_tree_mode: track_mode) do |sliced_input, response, page, pages, done, total| # rubocop:disable Metrics/ParameterLists, Layout/LineLength
42
- track_current_tree(response&.structure)
43
-
44
- results[stage] << (page_results = request_results_class.new(sliced_input, response))
45
- update_tags_remap_table(page_results, stage, current_tree)
90
+ inputs(
91
+ force_continue: force_continue?
92
+ ) do |input, stage|
93
+ next unless input
46
94
 
47
- self.error = page_errors?(page_results, page, pages, done, total, stage: stage)
48
- break if error
49
- end
95
+ sliced_batches(
96
+ input,
97
+ desc: stage,
98
+ track_tree_mode: batch_tree_track_mode(stage),
99
+ &results_tracking_block(stage: stage)
100
+ )
50
101
 
51
- break if error
102
+ break if error?
52
103
  rescue StandardError => err
53
104
  log(:error) { err.patch_full_message }
54
105
  raise
55
106
  end
56
107
  end
57
108
  ensure
58
- rescued { self.tags_remap_csv_file = generate_tags_remap_csv }
59
- rescued { close_handling_tags_remap_csv }
109
+ rescued { rearchive } unless exception
110
+ rescued { delete_or_publish_draft }
111
+ rescued { manage_remaps_table }
60
112
  end
61
113
  end
62
114
 
63
- # Default tree tacking behaviour
64
- # @note
65
- # 1. This aims to optimize the time run
66
- # 2. Based on update stage, there are differentiated tracking needs
67
- # @return [Symbol] the tracking mode
68
- def batch_tree_track_mode(stage)
69
- case stage
70
- when :unarchive, :archive
71
- :once
72
- when :id, :id_name
73
- :per_request
74
- when :insert, :move
75
- :per_batch
115
+ def results_tracking_block(stage:)
116
+ proc do |sliced_input, response, page, pages, done, total|
117
+ # yields the result of each batch
118
+
119
+ input_response = input_unit_response_class.new(
120
+ sliced_input,
121
+ response
122
+ )
123
+
124
+ results.add_response(
125
+ stage,
126
+ input_response
127
+ )
128
+
129
+ # @todo: might need to set the name and the id by treeifying here.
130
+ # Alternatively, add named arguments id and name.
131
+ track_current_tree(results.structure)
132
+
133
+ # early detection of errors
134
+ self.error ||= page_errors?(
135
+ input_response,
136
+ page,
137
+ pages,
138
+ done,
139
+ total,
140
+ stage: stage
141
+ )
142
+ end
143
+ end
144
+
145
+ private
146
+
147
+ # Work with adapted diff builders.
148
+ def nodes_diff_class
149
+ Eco::API::UseCases::GraphQL::Helpers::Location::Command::Diffs
150
+ end
151
+
152
+ # Before closing, run RE-ARCHIVE: those that where unarchived via archivedToken
153
+ # that should remain archived.
154
+ # @note this is an additional necessary step
155
+ def rearchive
156
+ return if exception?
157
+ return unless rearchive_comparer.respond_to?(:stage_commands)
158
+ return unless rearchive_diffs.any?
159
+
160
+ rearchive_commands = rearchive_comparer.stage_commands(:archive)
161
+ return unless rearchive_commands.any?
162
+
163
+ results.draft ||= create_draft(current_tree.id).draft
164
+
165
+ stage = :rearchive
166
+
167
+ rearchive_comparer.tap do
168
+ archive_input = input(
169
+ rearchive_commands,
170
+ force_continue: true
171
+ )
172
+
173
+ sliced_batches(
174
+ archive_input,
175
+ desc: stage,
176
+ track_tree_mode: :once,
177
+ &results_tracking_block(stage: stage)
178
+ )
179
+ rescue StandardError => err
180
+ log(:error) { err.patch_full_message }
181
+ raise
182
+ end
183
+ end
184
+
185
+ def rearchive_comparer
186
+ @rearchive_comparer ||= nodes_diff_class.new(
187
+ as_nodes_json(current_tree), # hash_list(current_tree),
188
+ file_nodes_list,
189
+ original_tree: current_tree,
190
+ logger: logger
191
+ )
192
+ end
193
+ alias_method :rearchive_diffs, :rearchive_comparer
194
+
195
+ def delete_or_publish_draft
196
+ return unless results.draft_id
197
+
198
+ if simulate? || error? || exception?
199
+ delete = true
200
+
201
+ if simulate?
202
+ delete = false
203
+ should_delete? { delete = true}
204
+ end
205
+
206
+ delete_draft(results.draft_id) if delete
76
207
  else
77
- default_tree_tracking_mode
208
+ results.final_response(
209
+ publish_draft(results.draft_id)
210
+ )
211
+ end
212
+ end
213
+
214
+ def should_delete?
215
+ session.prompt_user(
216
+ 'Should delete temporary draft? (Y/n):',
217
+ default: 'Y',
218
+ timeout: 5
219
+ ) do |response|
220
+ next unless response.upcase.start_with?('Y')
221
+
222
+ yield
78
223
  end
79
224
  end
225
+
226
+ def manage_remaps_table
227
+ return unless results.final_response?
228
+
229
+ rescued do
230
+ results.applied_commands(with_id_change: true) do |result|
231
+ update_tags_remap_table(result.command)
232
+ end
233
+ end
234
+
235
+ rescued { self.tags_remap_csv_file = generate_tags_remap_csv }
236
+ rescued { close_handling_tags_remap_csv }
237
+ end
80
238
  end
@@ -5,46 +5,78 @@ class Eco::API::UseCases::GraphQL::Samples::Location
5
5
 
6
6
  attr_accessor :error
7
7
 
8
- def request_results_class
8
+ def error?
9
+ !!error
10
+ end
11
+
12
+ def input_unit_response_class
13
+ Eco::API::UseCases::GraphQL::Helpers::Location::Command::InputUnitResponse
14
+ end
15
+
16
+ def run_results_class
9
17
  Eco::API::UseCases::GraphQL::Helpers::Location::Command::Results
10
18
  end
11
19
 
12
20
  # Capture results
13
21
  def results
14
- @results ||= {}
22
+ @results ||= run_results_class.new
15
23
  end
16
24
 
17
25
  # Errors tracking/logging.
18
26
  # @note it gives feedback on where an error has occurred.
19
- # @param page_results [Eco::API::UseCases::GraphQL::Helpers::Locations::Commands::CommandResults]
27
+ # @param input_unit_response [Eco::API::UseCases::GraphQL::Helpers::Locations::Commands::CommandResults]
20
28
  # @param stage [Symbol] used when we launch an update in different phases (i.e. rename, move, etc.)
21
29
  # @return [Boolean] whether or not there was an error
22
- def page_errors?(page_results, page, pages, done, total, stage: nil)
23
- msg = "Expecting CommandResults object. Given: #{page_results.class}"
24
- raise msg unless page_results.is_a?(request_results_class)
30
+ def page_errors?(input_unit_response, page, pages, done, total, stage: nil)
31
+ msg = "Expecting CommandResults object. Given: #{input_unit_response.class}"
32
+ raise msg unless input_unit_response.is_a?(input_unit_response_class)
25
33
 
26
34
  stage_str = stage ? "'#{stage}' " : ''
27
35
  fingerprint = "#{stage_str}#{page} (of #{pages})"
28
- errored = false
29
36
 
30
- if page_results.error?
37
+ if (errored = input_unit_response.error?)
38
+ log(:error) {
39
+ msg = "Error on #{fingerprint}: "
40
+ msg << JSON.pretty_generate(input_unit_response.error_doc)
41
+ msg
42
+ }
43
+ else
44
+ log(:info) {
45
+ "Success on #{fingerprint}: #{done} (of #{total}) commands added!"
46
+ }
47
+ end
48
+
49
+ errored
50
+ end
51
+
52
+ def result_errors?
53
+ errored = false
54
+
55
+ if results.error?
31
56
  errored = true
32
57
  log(:error) {
33
- "Error on #{fingerprint}: #{page_results.error.doc.pretty_inspect}"
58
+ msg = "Error on #{fingerprint}: "
59
+ msg << JSON.pretty_generate(input_unit_response.error_doc)
60
+ msg
34
61
  }
35
62
  end
36
63
 
37
- if page_results.applied?
64
+ # @todo: intermediate status check on drafts doesn't rely on applied
65
+ # This is rather to be done at the very end, when publishing the draft.
66
+ if input_unit_response.applied?
38
67
  log(:info) {
39
68
  "Success on #{fingerprint}: #{done} (of #{total}) commands applied!"
40
69
  }
41
- elsif page_results.errored?
70
+ elsif input_unit_response.errored?
42
71
  errored = true
43
- msg = "Some command failed on #{fingerprint}:\n#{page_results.stats}"
72
+ msg = "Some command failed on #{fingerprint}:\n"
73
+ msg << input_unit_response.stats
74
+
44
75
  unless force_continue?
45
- first_errored = page_results.first_errored
76
+ first_errored = input_unit_response.first_errored
46
77
  msg << "The error(s) - #{first_errored.error_msg}\n"
47
78
  end
79
+
48
80
  log(:error) { msg }
49
81
  end
50
82
 
@@ -9,7 +9,6 @@ class Eco::API::UseCases::GraphQL::Samples::Location
9
9
  def included(base)
10
10
  super
11
11
 
12
- base.send :include, Eco::API::UseCases::GraphQL::Samples::Location::Service::TreeDiff
13
12
  base.send :include, Eco::API::UseCases::GraphQL::Samples::Location::Command::DSL
14
13
  base.send :include, Eco::API::UseCases::GraphQL::Utils::Sftp
15
14
  base.send :include, InstanceMethods
@@ -22,43 +21,9 @@ class Eco::API::UseCases::GraphQL::Samples::Location
22
21
  super
23
22
  end
24
23
  ensure
25
- rescued { re_archive } unless exception?
26
24
  rescued { email_digest('TagTree Update') }
27
25
  end
28
26
 
29
- # Before closing, run RE-ARCHIVE: those that where unarchived via archivedToken
30
- # that should remain archived.
31
- # @note this is an additional necessary step
32
- def re_archive
33
- return if simulate?
34
- return if exception?
35
-
36
- stage = :rearchive
37
-
38
- nodes_diff_class.new(
39
- hash_list(current_tree),
40
- file_nodes_list,
41
- original_tree: current_tree,
42
- logger: logger
43
- ).tap do |nodes_diff|
44
- archive_input = input(
45
- nodes_diff.stage_commands(:archive),
46
- force_continue: true
47
- )
48
-
49
- sliced_batches(
50
- archive_input,
51
- desc: stage,
52
- track_tree_mode: :once
53
- ) do |sliced_input, response, page, pages, count, total| # rubocop:disable Metrics/ParameterLists
54
- page_results = request_results_class.new(sliced_input, response)
55
- (results[stage] ||= []) << page_results
56
-
57
- self.error ||= page_errors?(page_results, page, pages, count, total, stage: stage)
58
- end
59
- end
60
- end
61
-
62
27
  private
63
28
 
64
29
  # Work with adapted diff builders.
@@ -66,18 +31,6 @@ class Eco::API::UseCases::GraphQL::Samples::Location
66
31
  Eco::API::UseCases::GraphQL::Helpers::Location::Command::Diffs
67
32
  end
68
33
 
69
- def inputs(nodes_diff = comparer, force_continue: force_continue?)
70
- {}.tap do |sequence|
71
- nodes_diff.commands do |comms, stage|
72
- sequence[stage] = input(comms, force_continue: force_continue)
73
- end
74
- end.tap do |sequence|
75
- sequence.each do |stage, input|
76
- yield(input, stage) if block_given?
77
- end
78
- end
79
- end
80
-
81
34
  # Generates the file and pushes to the SFTP folder
82
35
  # @note it also displays the mappings on screen
83
36
  # @note the SFTP push only happens if `remote_subfolder` is defined, via:
@@ -106,10 +59,6 @@ class Eco::API::UseCases::GraphQL::Samples::Location
106
59
  options.deep_merge!({worfklow: {no_email: true}})
107
60
  end
108
61
  end
109
-
110
- def print_diff_details?
111
- false
112
- end
113
62
  end
114
63
  end
115
64
  end
@@ -28,7 +28,7 @@ class Eco::API::UseCases::GraphQL::Samples::Location
28
28
  # @note this method used to only work if we could run cummulative dry-runs to the back-end.
29
29
  # However, after RS P3, as mappings are one-to-one (not many-to-many per row),
30
30
  # we can just display the mappings in dry-run as well.
31
- def close_handling_tags_remap_csv
31
+ def close_handling_tags_remap_csv # rubocop:disable Naming/PredicateMethod
32
32
  if tags_remap_table.any?
33
33
  puts "REMAP LOC IDs CSV (content):"
34
34
  puts tags_remap_table
@@ -44,21 +44,13 @@ class Eco::API::UseCases::GraphQL::Samples::Location
44
44
  # @note The only update operation that generate tag remaps
45
45
  # is `:id` (or `:id_name`).
46
46
  # @return [Boolean] whether new maps were inserted to the tracking table
47
- def update_tags_remap_table(results, stage, ref_tree = nil)
48
- return false unless %i[id id_name].include?(stage)
47
+ def update_tags_remap_table(command)
48
+ prev_id, new_id = command.values_at(:nodeId, :newId)
49
49
 
50
- msg = "Expecting CommandResults object. Given: #{results.class}"
51
- raise msg unless results.is_a?(request_results_class)
50
+ return if new_id.nil? # not an id change
51
+ return if prev_id == new_id
52
52
 
53
- target = simulate?? results.results : results.applied
54
-
55
- target.each do |result|
56
- prev_id, new_id = result.command_input_data.values_at(:nodeId, :newId)
57
- next if new_id.nil? # not an id change
58
- next if prev_id == new_id
59
-
60
- tags_remap_table << [[prev_id], [new_id]]
61
- end
53
+ tags_remap_table << [[prev_id], [new_id]]
62
54
  end
63
55
 
64
56
  # Generates the final tags remap file
@@ -1,7 +1,7 @@
1
1
  # Use case to launch updates to a tagtree (i.e. upload new locations)
2
2
  module Eco::API::UseCases::GraphQL::Samples
3
3
  class Location::Command < Eco::API::UseCases::GraphQL::Samples::Location
4
- name "location-command"
4
+ name 'location-command'
5
5
 
6
6
  require_relative 'command/results'
7
7
  require_relative 'command/track_changed_ids'
@@ -38,7 +38,10 @@ module Eco::API::UseCases::GraphQL::Samples::Location::Service
38
38
 
39
39
  #@note via Eco::Data::Files
40
40
  def csv_files
41
- self.class.csv_files(input_folder, regexp: input_file_pattern)
41
+ self.class.csv_files(
42
+ input_folder,
43
+ regexp: input_file_pattern
44
+ )
42
45
  end
43
46
 
44
47
  def input_file_pattern
@@ -53,6 +53,8 @@ module Eco::API::UseCases::GraphQL::Samples
53
53
 
54
54
  def process
55
55
  with_error_handling do
56
+ next unless compare_live_with_file?
57
+
56
58
  compare
57
59
  end
58
60
  end
@@ -87,6 +89,10 @@ module Eco::API::UseCases::GraphQL::Samples
87
89
  Eco::Data::Locations::NodeDiff::NodesDiff
88
90
  end
89
91
 
92
+ def compare_live_with_file?
93
+ true
94
+ end
95
+
90
96
  def print_diff_details?
91
97
  true
92
98
  end
@@ -6,6 +6,7 @@ module Eco::API::UseCases::GraphQL::Samples::Location::Service
6
6
 
7
7
  private
8
8
 
9
+ # @todo this name is confusing. It is actually the `current_tagtree` :D
9
10
  def input_tagtree
10
11
  @input_tagtree ||= live_tree
11
12
  end
@@ -30,7 +30,7 @@ module Eco::API::UseCases::Lib
30
30
  def rescued
31
31
  yield
32
32
  rescue StandardError => err
33
- self.exception ||= err
33
+ @exception ||= err
34
34
 
35
35
  return unless exception_already_captured?(err)
36
36
 
@@ -42,6 +42,7 @@ module Eco
42
42
  class << self
43
43
  def included(base)
44
44
  super
45
+
45
46
  validate_base_type!(base)
46
47
  base.include(InstanceMethods)
47
48
  end
@@ -40,6 +40,7 @@ module Eco
40
40
  class << self
41
41
  def included(base)
42
42
  super
43
+
43
44
  validate_base_type!(base)
44
45
  base.include(InstanceMethods)
45
46
  end
@@ -1,4 +1,4 @@
1
- class Eco::API::UseCases::Samples::Drivers::Sftp
1
+ class Eco::API::UseCases::Samples::Drivers::Sftp
2
2
  class Cli < Eco::API::UseCases::Cli
3
3
  desc 'SFTP case: manages remote files that match a file pattern'
4
4
 
@@ -28,7 +28,10 @@ class Eco::API::UseCases::Samples::Drivers::Sftp < Eco::API::Common::Loaders::Us
28
28
 
29
29
  def list_folder
30
30
  puts "Listing remote folder: '#{remote_folder}' (host: #{sftp.host}):"
31
- with_remote_files(pattern: file_pattern) {|file| puts file.longname}
31
+
32
+ with_remote_files(pattern: file_pattern) do |file|
33
+ puts file.longname
34
+ end
32
35
  end
33
36
 
34
37
  def get_files
@@ -38,6 +38,7 @@ class Eco::API::UseCases::Samples::Drivers::UrlPull < Eco::API::Common::Loaders:
38
38
  base_request(uri, **kargs) do |request|
39
39
  http_start(uri) do |http|
40
40
  puts "Pulling from url: #{uri}"
41
+
41
42
  return http.request(request)
42
43
  end
43
44
  end
@@ -73,6 +74,7 @@ class Eco::API::UseCases::Samples::Drivers::UrlPull < Eco::API::Common::Loaders:
73
74
  def base_request(uri, user: nil, pass: '')
74
75
  Net::HTTP::Get.new(uri).tap do |request|
75
76
  request.basic_auth(user, pass) unless user.nil?
77
+
76
78
  yield(request)
77
79
  end
78
80
  end
@@ -91,6 +93,7 @@ class Eco::API::UseCases::Samples::Drivers::UrlPull < Eco::API::Common::Loaders:
91
93
 
92
94
  def target_url(required: true)
93
95
  fpc = target_url_const
96
+
94
97
  return fpc if fpc
95
98
  return unless required
96
99
 
@@ -99,15 +102,15 @@ class Eco::API::UseCases::Samples::Drivers::UrlPull < Eco::API::Common::Loaders:
99
102
  end
100
103
 
101
104
  def target_url_const
102
- if (fpc = options.dig(:url_pull, :target_url_const))
103
- msg = "(#{self.class}) Invalid file pattern const referral: #{fpc}"
104
- raise WrongConst, msg unless fpc.match(CONST_REFERRAL)
105
-
106
- begin
107
- self.eval(fpc)
108
- rescue NameError
109
- self.class.const_get(fpc)
110
- end
105
+ return unless (fpc = options.dig(:url_pull, :target_url_const))
106
+
107
+ msg = "(#{self.class}) Invalid file pattern const referral: #{fpc}"
108
+ raise WrongConst, msg unless fpc.match(CONST_REFERRAL)
109
+
110
+ begin
111
+ self.eval(fpc)
112
+ rescue NameError
113
+ self.class.const_get(fpc)
111
114
  end
112
115
  rescue NameError
113
116
  raise WrongConst, "(#{self.class}) Unknown constant: #{fpc}"
@@ -0,0 +1,5 @@
1
+ class Eco::API::UseCases::Samples::People::Filters::RequireId
2
+ class Cli < Eco::API::UseCases::Cli
3
+ desc 'Import case to discard entries that do NOT have a unique identifier (external_id)'
4
+ end
5
+ end
@@ -0,0 +1,5 @@
1
+ class Eco::API::UseCases::Samples::People::Filters::RequireMinEntries
2
+ class Cli < Eco::API::UseCases::Cli
3
+ desc 'Import case to halt if MIN_COUNT is NOT met'
4
+ end
5
+ end