eco-helpers 3.0.37 → 3.1.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 (138) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +1 -0
  3. data/CHANGELOG.md +148 -1
  4. data/eco-helpers.gemspec +2 -2
  5. data/lib/eco/api/common/loaders/base.rb +2 -2
  6. data/lib/eco/api/common/loaders/case_base.rb +2 -0
  7. data/lib/eco/api/common/loaders/config/block.rb +78 -0
  8. data/lib/eco/api/common/loaders/config/workflow/mailer.rb +49 -8
  9. data/lib/eco/api/common/loaders/config.rb +3 -26
  10. data/lib/eco/api/common/loaders/error_handler.rb +2 -0
  11. data/lib/eco/api/common/loaders/parser.rb +1 -4
  12. data/lib/eco/api/common/people/entries.rb +23 -6
  13. data/lib/eco/api/common/people/entry_factory.rb +1 -1
  14. data/lib/eco/api/common/people/person_entry.rb +104 -27
  15. data/lib/eco/api/common/people/person_parser.rb +50 -16
  16. data/lib/eco/api/common/people/supervisor_helpers.rb +12 -6
  17. data/lib/eco/api/common/session/base_session.rb +75 -81
  18. data/lib/eco/api/common/session/environment.rb +70 -70
  19. data/lib/eco/api/common/session/file_manager.rb +132 -135
  20. data/lib/eco/api/common/session/helpers/prompt_user.rb +23 -30
  21. data/lib/eco/api/common/session/helpers.rb +10 -15
  22. data/lib/eco/api/common/session/logger/cache.rb +94 -96
  23. data/lib/eco/api/common/session/logger/channels.rb +24 -32
  24. data/lib/eco/api/common/session/logger/log.rb +38 -46
  25. data/lib/eco/api/common/session/logger.rb +50 -54
  26. data/lib/eco/api/common/session/mailer/aws_provider.rb +64 -71
  27. data/lib/eco/api/common/session/mailer/provider_base.rb +43 -48
  28. data/lib/eco/api/common/session/mailer/sendgrid_provider.rb +101 -109
  29. data/lib/eco/api/common/session/mailer.rb +78 -83
  30. data/lib/eco/api/common/session/s3_uploader.rb +132 -138
  31. data/lib/eco/api/common/session/sftp.rb +202 -208
  32. data/lib/eco/api/common.rb +0 -3
  33. data/lib/eco/api/custom/mailer.rb +4 -2
  34. data/lib/eco/api/error/handlers.rb +1 -1
  35. data/lib/eco/api/microcases/people/apply_changes/set_core/core_excluded.rb +8 -2
  36. data/lib/eco/api/microcases/people/manage/search.rb +2 -2
  37. data/lib/eco/api/organization/people/similarity.rb +3 -3
  38. data/lib/eco/api/organization/people.rb +2 -2
  39. data/lib/eco/api/session/batch/base_policy.rb +42 -27
  40. data/lib/eco/api/session/batch/launcher/mode_size.rb +6 -1
  41. data/lib/eco/api/session/batch/launcher.rb +16 -3
  42. data/lib/eco/api/session/config/api.rb +4 -3
  43. data/lib/eco/api/session/config/apis/one_off.rb +1 -1
  44. data/lib/eco/api/session/config/files.rb +13 -12
  45. data/lib/eco/api/session/config/workflow.rb +1 -373
  46. data/lib/eco/api/session/config.rb +47 -11
  47. data/lib/eco/api/session.rb +7 -9
  48. data/lib/eco/api/usecases/base_case/model.rb +6 -6
  49. data/lib/eco/api/usecases/base_case.rb +1 -1
  50. data/lib/eco/api/usecases/cli.rb +1 -1
  51. data/lib/eco/api/usecases/default/locations/tagtree_extract_case.rb +22 -13
  52. data/lib/eco/api/usecases/default_cases/to_csv_case.rb +4 -1
  53. data/lib/eco/api/usecases/graphql/helpers/location/tags_remap.rb +6 -3
  54. data/lib/eco/api/usecases/graphql/samples/location/command/dsl.rb +2 -2
  55. data/lib/eco/api/usecases/lib/base/env.rb +21 -23
  56. data/lib/eco/api/usecases/lib/files/file_pattern.rb +41 -14
  57. data/lib/eco/api/usecases/lib/files/input_file.rb +110 -0
  58. data/lib/eco/api/usecases/lib/files/sftp.rb +5 -2
  59. data/lib/eco/api/usecases/lib/files.rb +1 -0
  60. data/lib/eco/api/usecases/lib/locations/base.rb +23 -0
  61. data/lib/eco/api/usecases/lib/locations/mapping.rb +94 -0
  62. data/lib/eco/api/usecases/lib/locations.rb +7 -0
  63. data/lib/eco/api/usecases/lib/people/base.rb +20 -0
  64. data/lib/eco/api/usecases/lib/people.rb +6 -0
  65. data/lib/eco/api/usecases/lib.rb +2 -0
  66. data/lib/eco/api/usecases/ooze_cases.rb +1 -1
  67. data/lib/eco/api/usecases/ooze_samples/ooze_base_case.rb +1 -1
  68. data/lib/eco/api/usecases/ooze_samples/ooze_from_doc_case.rb +3 -3
  69. data/lib/eco/api/usecases/ooze_samples/ooze_run_base_case.rb +4 -1
  70. data/lib/eco/api/usecases/ooze_samples/ooze_update_case.rb +1 -1
  71. data/lib/eco/api/usecases/ooze_samples/register_export_case.rb +6 -2
  72. data/lib/eco/api/usecases/ooze_samples/register_migration_case.rb +7 -6
  73. data/lib/eco/api/usecases/ooze_samples/register_update_case.rb +14 -4
  74. data/lib/eco/api/usecases/ooze_samples/target_oozes_update_case.rb +11 -8
  75. data/lib/eco/api/usecases/samples/drivers/sftp_sample.rb +2 -0
  76. data/lib/eco/api/usecases/samples/drivers/url_pull_sample.rb +8 -2
  77. data/lib/eco/api/usecases/service/sftp/with_target_config.rb +0 -33
  78. data/lib/eco/api/usecases/service/sftp.rb +7 -1
  79. data/lib/eco/api/usecases/use_case.rb +3 -2
  80. data/lib/eco/api/usecases/workflow.rb +5 -0
  81. data/lib/eco/api/usecases.rb +12 -5
  82. data/lib/eco/cli/scripting/args_helpers.rb +1 -9
  83. data/lib/eco/cli_default/options.rb +98 -68
  84. data/lib/eco/cli_default/workflow/end.rb +22 -0
  85. data/lib/eco/cli_default/workflow/launch_jobs.rb +14 -0
  86. data/lib/eco/cli_default/workflow/load/data.rb +27 -0
  87. data/lib/eco/cli_default/workflow/load/input.rb +28 -0
  88. data/lib/eco/cli_default/workflow/load.rb +13 -0
  89. data/lib/eco/cli_default/workflow/options.rb +18 -0
  90. data/lib/eco/cli_default/workflow/post_launch.rb +65 -0
  91. data/lib/eco/cli_default/workflow/report.rb +17 -0
  92. data/lib/eco/cli_default/workflow/rescued_exception.rb +21 -0
  93. data/lib/eco/cli_default/workflow/usecases.rb +23 -0
  94. data/lib/eco/cli_default/workflow.rb +24 -177
  95. data/lib/eco/data/count_trace.rb +51 -0
  96. data/lib/eco/data/files/content.rb +39 -0
  97. data/lib/eco/data/files/directory.rb +78 -45
  98. data/lib/eco/data/files/encoding.rb +12 -21
  99. data/lib/eco/data/files/file_pattern.rb +15 -8
  100. data/lib/eco/data/files/folder.rb +196 -0
  101. data/lib/eco/data/files/relative_path.rb +54 -0
  102. data/lib/eco/data/files/timestamp.rb +18 -0
  103. data/lib/eco/data/files.rb +46 -5
  104. data/lib/eco/data/fuzzy_match.rb +1 -1
  105. data/lib/eco/data/hashes/array_diff.rb +11 -5
  106. data/lib/eco/data/hashes/diff_result/meta.rb +12 -4
  107. data/lib/eco/data/locations/node_diff/accessors.rb +1 -1
  108. data/lib/eco/data/mapper.rb +8 -1
  109. data/lib/eco/data.rb +1 -0
  110. data/lib/eco/language/auxiliar_logger.rb +6 -11
  111. data/lib/eco/language/delegation/delegating_missing.rb +1 -1
  112. data/lib/eco/language/delegation/delegating_missing_const.rb +1 -1
  113. data/lib/eco/language/delegation/delegating_missing_on_class.rb +1 -1
  114. data/lib/eco/language/delegation/for_delegator/delegated_class.rb +1 -1
  115. data/lib/eco/language/klass/auto_loader.rb +129 -0
  116. data/lib/eco/language/klass/builder.rb +6 -6
  117. data/lib/eco/language/klass/const.rb +19 -0
  118. data/lib/eco/language/klass/helpers_built.rb +3 -1
  119. data/lib/eco/language/klass/hierarchy.rb +5 -1
  120. data/lib/eco/language/klass/inheritable_class_vars.rb +9 -6
  121. data/lib/eco/language/klass/naming.rb +5 -2
  122. data/lib/eco/language/klass/resolver.rb +21 -6
  123. data/lib/eco/language/klass/uid.rb +12 -0
  124. data/lib/eco/language/klass/when_inherited.rb +30 -6
  125. data/lib/eco/language/klass.rb +5 -2
  126. data/lib/eco/language/methods/access_modifier.rb +23 -0
  127. data/lib/eco/language/methods/instance_method_helpers.rb +6 -1
  128. data/lib/eco/language/methods.rb +1 -0
  129. data/lib/eco/language/models/hierarchy.rb +41 -0
  130. data/lib/eco/language/models/workflow.rb +404 -0
  131. data/lib/eco/language/models.rb +2 -1
  132. data/lib/eco/version.rb +1 -1
  133. metadata +39 -15
  134. data/lib/eco/api/common/class_auto_loader.rb +0 -114
  135. data/lib/eco/api/common/class_helpers.rb +0 -9
  136. data/lib/eco/api/common/class_hierarchy.rb +0 -45
  137. data/lib/eco/data/files/helpers.rb +0 -152
  138. data/lib/eco/language/models/class_helpers.rb +0 -136
@@ -0,0 +1,404 @@
1
+ module Eco::Language::Models
2
+ # Execution workflow
3
+ class Workflow
4
+ extend Eco::Language::Klass::HelpersBuilt
5
+ extend Eco::Language::Models::Hierarchy
6
+
7
+ class << self
8
+ def stages
9
+ model_attrs
10
+ end
11
+
12
+ def model
13
+ super || {}
14
+ end
15
+
16
+ def validate_stage!(stage)
17
+ return true if stages.include?(stage)
18
+
19
+ msg = "Unknown Workflow stage '#{stage}'. Should be any of #{stages}"
20
+ raise ArgumentError, msg
21
+ end
22
+
23
+ def workflow_class(key, prefix: nil)
24
+ class_name = "#{key}::#{uid}"
25
+ class_name = "#{prefix}::#{class_name}" if prefix
26
+ class_name = to_constant(class_name)
27
+
28
+ new_class(
29
+ class_name,
30
+ inherits: Eco::API::Session::Config::Workflow
31
+ ) do |klass|
32
+ klass.model = model[key]
33
+ end
34
+ end
35
+ end
36
+
37
+ attr_reader :config
38
+
39
+ def initialize(name = nil, config:, _parent: self) # rubocop:disable Lint/UnderscorePrefixedVariableName
40
+ @config = config
41
+ @name = name || 'root'
42
+
43
+ @stages = {}
44
+ @_parent = _parent
45
+
46
+ @pending = true
47
+ # moments
48
+ @on = nil
49
+ @before = []
50
+ @after = []
51
+ end
52
+
53
+ # We don't support cloning
54
+ def clone
55
+ self
56
+ end
57
+ alias_method :dup, :clone
58
+
59
+ def name(with_path: false)
60
+ return @name if !with_path || root?
61
+
62
+ [@_parent.name(with_path: true), @name].compact.join('.')
63
+ end
64
+
65
+ # Has this stage run yet?
66
+ # @note it does **not** include _sub-stages_ that run `before`
67
+ # @return [Boolean] `true` if it has run, `false` otherwise
68
+ def pending?
69
+ @pending
70
+ end
71
+
72
+ # Do not run this stage!
73
+ def skip!
74
+ @skip = true
75
+ @pending = false
76
+ end
77
+
78
+ # Has this stage been marked as to be skipped
79
+ # @return [Boolean] depends on this order:
80
+ # - `true` if `skip!` was called
81
+ # - `false` if the current _stage_ is `root?` (the top stage of the hierarchy)
82
+ # - `true` if its parent task is to be skipped
83
+ def skip?
84
+ return @skip if instance_variable_defined?(:@skip)
85
+ return false if root?
86
+
87
+ @_parent.skip?
88
+ end
89
+
90
+ # Used in **configuration** time **to configure** the _workflow_ of the target (sub)stage `key`
91
+ # @note
92
+ # 1. if a `block` is provided it will `yield` the target stage immediately
93
+ # 2. a `block` is only required when `key` has not been specified.
94
+ # @param key [Symbol, nil] cases:
95
+ # - if `key` is not provided, it targets the _current stage_
96
+ # - if `key` is provided, it targets the specific _sub-stage_
97
+ # @yield [stage_workflow] further _workflow_ configuration `for` the target stage `key`
98
+ # @yieldparam stage_workflow [Eco::API::Session::Config::Workflow] the _target stage_ referred by `key`
99
+ # @return [Eco::API::Session::Config::Workflow]
100
+ # 1. if block is provided provided, it returns the **current stage** object (to ease chainig).
101
+ # 2. if block is not provided, it returns the **stage** referred by `key`
102
+ def for(key = nil, &block)
103
+ msg = "With no 'key', a block should be given."
104
+ raise ArgumentError, msg unless key || block_given?
105
+
106
+ tap do
107
+ next yield(self) unless key
108
+ next stage(key).for(&block) if block_given?
109
+
110
+ return stage(key)
111
+ end
112
+ end
113
+ alias_method :with, :for
114
+
115
+ # Used in **configuration** time **to define** the **behaviour** the target (sub)stage `key`
116
+ # @note if a `block` is provided it will **not** `yield` the target stage immediately,
117
+ # but when the _workflow_ reaches the stage
118
+ # @param key [Symbol, nil] cases:
119
+ # - if `key` is not provided, it targets the _current stage_
120
+ # - if `key` is provided, it targets the specific _sub-stage_
121
+ # @yield [stage_workflow, io] the behaviour of the target stage `key` when the _workflow_ reaches it
122
+ # @yieldparam stage_workflow [Eco::API::Session::Config::Workflow] the _target stage_ referred by `key`
123
+ # @yieldparam io [INPUT_OUTPUT_CLASS] the input/output object carried througout all the _workflow_
124
+ # @yieldreturn [INPUT_OUTPUT_CLASS] the `io` input/output object carried througout all the _workflow_
125
+ # @return [Eco::API::Session::Config::Workflow] the current stage object (to ease chainig).
126
+ def on(key = nil, &block)
127
+ msg = 'A block should be given.'
128
+ raise ArgumentError, msg unless block_given?
129
+
130
+ if key
131
+ stage(key).on(&block)
132
+ else
133
+ @on = block
134
+ end
135
+
136
+ self
137
+ end
138
+
139
+ # When there is an `Exception`, you might have defined some `callback`
140
+ # to do something with it (i.e. register, email)
141
+ # @yield [exception, io] the `callback` to do something with
142
+ # an `Exception` raised within this _workflow_ stage
143
+ # @yieldparam exception [Exception] the exception object that was raised
144
+ # @yieldparam io [INPUT_OUTPUT_CLASS] the input/output object carried througout all the _workflow_
145
+ # @yieldreturn [INPUT_OUTPUT_CLASS] the `io` input/output object carried througout all the _workflow_
146
+ # @return [Eco::API::Session::Config::Workflow] the current stage object (to ease chainig).
147
+ def rescue(&block)
148
+ return @rescue unless block_given?
149
+
150
+ @rescue = block
151
+ self
152
+ end
153
+ # Prevent reserved word clash on DSL
154
+ alias_method :exception, :rescue
155
+
156
+ # Called on `SystemExit` exception
157
+ def exit_handle(&block)
158
+ return @exit_handle unless block_given?
159
+
160
+ @exit_handle = block
161
+ self
162
+ end
163
+
164
+ # Used in **configuration** time **add previous** `callbacks`
165
+ # **before** the `on` _callback_ of the (sub)stage `key` is actually `run`
166
+ # @note
167
+ # - it will **not** `yield` it immediately, but when the _workflow_ reaches the target stage
168
+ # - in this case, you can define multiple `callbacks`
169
+ # @param key [Symbol, nil] cases:
170
+ # - if `key` is not provided, it targets the _current stage_
171
+ # - if `key` is provided, it targets the specific _sub-stage_
172
+ # @yield [stage_workflow, io] one of the things to do **before** the
173
+ # `on` _callback_ of the (sub)stage `key` is actually `run`
174
+ # @yieldparam stage_workflow [Eco::API::Session::Config::Workflow] the _target stage_ referred by `key`
175
+ # @yieldparam io [INPUT_OUTPUT_CLASS] the input/output object carried througout all the _workflow_
176
+ # @yieldreturn [INPUT_OUTPUT_CLASS] `io` the input/output object carried througout all the _workflow_
177
+ # @return [Eco::API::Session::Config::Workflow] the current stage object (to ease chainig).
178
+ def before(key = nil, &block)
179
+ msg = 'A block should be given.'
180
+ raise ArgumentError, msg unless block_given?
181
+
182
+ if key
183
+ stage(key).before(&block)
184
+ else
185
+ @before.push(block)
186
+ end
187
+
188
+ self
189
+ end
190
+
191
+ # Used in **configuration** time **add previous** `callbacks` **after** the `on` _callback_
192
+ # of the (sub)stage `key` is actually `run`
193
+ # @note
194
+ # - it will **not** `yield` it immediately, but when the _workflow_ reaches the target stage
195
+ # - in this case, you can define multiple `callbacks`
196
+ # @param key [Symbol, nil] cases:
197
+ # - if `key` is not provided, it targets the _current stage_
198
+ # - if `key` is provided, it targets the specific _sub-stage_
199
+ # @yield [stage_workflow, io] one of the things to do **after** the
200
+ # `on` _callback_ of the (sub)stage `key` is actually `run`
201
+ # @yieldparam stage_workflow [Eco::API::Session::Config::Workflow] the _target stage_ referred by `key`
202
+ # @yieldparam io [INPUT_OUTPUT_CLASS] the input/output object carried througout all the _workflow_
203
+ # @yieldreturn [INPUT_OUTPUT_CLASS] `io` the input/output object carried througout all the _workflow_
204
+ # @return [Eco::API::Session::Config::Workflow] the current stage object (to ease chainig).
205
+ def after(key = nil, &block)
206
+ msg = 'A block should be given.'
207
+ raise ArgumentError, msg unless block_given?
208
+
209
+ if key
210
+ stage(key).after(&block)
211
+ else
212
+ @after.push(block)
213
+ end
214
+
215
+ self
216
+ end
217
+
218
+ # Used in run time to **execute the workflow** of the (sub)stage `key`
219
+ # @note if a `block` is **not** provided:
220
+ # - it will run the `before` _callbacks_ defined during the configuration time
221
+ # - it will run the _workflow_ of any defined _**substage**_ of the `key` stage
222
+ # - it will run the `on` _callback_ defined during the configuration time
223
+ # - it will mark the stage as **not** `pending?`.
224
+ # - it will run the `after` _callbacks_ defined during the configuration time
225
+ # @note if a `block` is provided:
226
+ # - it will **not** run the workflow of the substages to `key` stage
227
+ # - it will **not** run the `callback` for `on` defined during the configuration time
228
+ # - it will rather `yield` the target stage after all the `before` _callbacks_ have been run
229
+ # - aside of this, the rest will be the same as when the _block_ is provided (see previous note)
230
+ # @note [if the object returned by `before`, `after` and `run` callbacks
231
+ # is not an `INPUT_OUTPUT_CLASS`, the original `io` object will be returned instead.
232
+ # @param key [Symbol, nil] cases:
233
+ # - if `key` is not provided, it targets the _current stage_
234
+ # - if `key` is provided, it targets the specific _sub-stage_
235
+ # @param io [INPUT_OUTPUT_CLASS] the input/output object
236
+ # @yield [stage_workflow, io] if a `block` is provided, see `note`
237
+ # @yieldparam stage_workflow [Eco::API::Session::Config::Workflow] the _target stage_ referred by `key`
238
+ # @yieldparam io [INPUT_OUTPUT_CLASS] the input/output object carried througout all the _workflow_
239
+ # @yieldreturn [INPUT_OUTPUT_CLASS] the `io` input/output object carried througout all the _workflow_
240
+ # @return [Eco::API::Session::Config::Workflow] the current stage object (to ease chainig).
241
+ def run(key = nil, io:, &block)
242
+ raise 'Missing BaseIO object' unless io.is_a?(input_output_class)
243
+
244
+ rescuable(io) do
245
+ if key
246
+ io = io_result(io: io) do
247
+ stage(key).run(io: io, &block)
248
+ end
249
+ elsif pending?
250
+ io = run_before(io)
251
+ io = run_it(io, &block) unless skip?
252
+ io = run_after(io)
253
+ end
254
+
255
+ io
256
+ ensure
257
+ @pending = false
258
+ end
259
+ end
260
+
261
+ protected
262
+
263
+ def root?
264
+ @_parent == self
265
+ end
266
+
267
+ def path
268
+ return name if root?
269
+
270
+ "#{@_parent.path}:#{name}"
271
+ end
272
+
273
+ def ready?
274
+ !!@on
275
+ end
276
+
277
+ def run_before(io)
278
+ io.session.log(:debug) {
279
+ "(Workflow: #{path}) running before callbacks..."
280
+ }
281
+
282
+ @before.each do |c|
283
+ io = io_result(io: io) do
284
+ io.evaluate(self, io, &c)
285
+ end
286
+ end
287
+
288
+ io
289
+ end
290
+
291
+ def run_after(io)
292
+ io.session.log(:debug) {
293
+ "(Workflow: #{path}) ...running after callbacks"
294
+ }
295
+
296
+ @after.each do |c|
297
+ io = io_result(io: io) do
298
+ io.evaluate(self, io, &c)
299
+ end
300
+ end
301
+
302
+ io
303
+ end
304
+
305
+ def run_it(io, &block)
306
+ io.session.log(:debug) {
307
+ "(Workflow: #{path}) running now"
308
+ }
309
+
310
+ if block
311
+ io = io_result(io: io) do
312
+ io.evaluate(self, io, &block)
313
+ end
314
+ else
315
+ existing_stages.each do |stg|
316
+ io = io_result(io: io) do
317
+ stg.run(io: io)
318
+ end
319
+ end
320
+
321
+ unless ready?
322
+ io.session.log(:debug) {
323
+ "(Workflow: #{path}) 'on' callback is not defined, nor block given"
324
+ }
325
+ end
326
+
327
+ io = io_result(io: io) do
328
+ io.evaluate(self, io, &@on)
329
+ end
330
+ end
331
+
332
+ io
333
+ ensure
334
+ @pending = false
335
+ end
336
+
337
+ # It ensures an `INPUT_OUTPUT_CLASS` is returned
338
+ # @note it always brings the IO to be a `BaseIO`.
339
+ # As the `output` and the type is captured, it just cleans usecase related
340
+ # logic from the object.
341
+ # @raise ArgumentError if `klass` isn't child of `INPUT_OUTPUT_CLASS`
342
+ # @return [INPUT_OUTPUT_CLASS] the `io` input/output object carried througout the _workflow_
343
+ def io_result(io:, klass: input_output_class)
344
+ msg = "Expecting class to be child of #{input_output_class}. Given: #{klass}"
345
+ raise ErrorArgument, msg unless klass <= input_output_class
346
+
347
+ result = yield
348
+ io = result if result.is_a?(klass)
349
+ io.instance_of?(klass) ? io : io.base
350
+ end
351
+
352
+ def existing_stages
353
+ # sort defined stages by stage order
354
+ sorted_keys = self.class.stages & @stages.keys
355
+ sorted_keys.map {|k| stage(k)}
356
+ end
357
+
358
+ def ready_stages
359
+ exiting_stages.select(&:ready?)
360
+ end
361
+
362
+ def stages_ready?
363
+ existing_stages.all?(&:ready?)
364
+ end
365
+
366
+ def stage(key)
367
+ self.class.validate_stage!(key)
368
+ prefix = path.gsub(':', '::')
369
+
370
+ @stages[key] ||= self.class.workflow_class(key, prefix: prefix).new(
371
+ key,
372
+ _parent: self,
373
+ config: config
374
+ )
375
+ end
376
+
377
+ def input_output_class
378
+ self.class::INPUT_OUTPUT_CLASS
379
+ end
380
+
381
+ # helper to treat trigger the exit and rescue handlers
382
+ def rescuable(io)
383
+ yield
384
+ # rescue SystemStackError => err
385
+ # puts err.patch_full_message(trace_count: 100)
386
+ # exit 1
387
+ rescue SystemExit => err
388
+ io = io_result(io: io) do
389
+ io.evaluate(err, io, &exit_handle)
390
+ end
391
+
392
+ exit err.status
393
+ rescue Interrupt => _int
394
+ raise
395
+ rescue StandardError => err
396
+ # raise unless self.rescue
397
+ io = io_result(io: io) do
398
+ io.evaluate(err, io, &self.rescue)
399
+ end
400
+
401
+ raise
402
+ end
403
+ end
404
+ end
@@ -5,8 +5,9 @@ module Eco
5
5
  end
6
6
  end
7
7
 
8
- require_relative 'models/class_helpers'
9
8
  require_relative 'models/modifier'
9
+ require_relative 'models/hierarchy'
10
+ require_relative 'models/workflow'
10
11
  require_relative 'models/collection'
11
12
  require_relative 'models/parser_serializer'
12
13
  require_relative 'models/wrap'
data/lib/eco/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Eco
2
- VERSION = '3.0.37'.freeze
2
+ VERSION = '3.1.3'.freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: eco-helpers
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.37
4
+ version: 3.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Oscar Segura
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2025-04-15 00:00:00.000000000 Z
11
+ date: 2025-05-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: byebug
@@ -260,40 +260,40 @@ dependencies:
260
260
  requirements:
261
261
  - - "~>"
262
262
  - !ruby/object:Gem::Version
263
- version: '0.4'
263
+ version: '1.1'
264
264
  - - ">="
265
265
  - !ruby/object:Gem::Version
266
- version: 0.4.5
266
+ version: 1.1.1
267
267
  type: :runtime
268
268
  prerelease: false
269
269
  version_requirements: !ruby/object:Gem::Requirement
270
270
  requirements:
271
271
  - - "~>"
272
272
  - !ruby/object:Gem::Version
273
- version: '0.4'
273
+ version: '1.1'
274
274
  - - ">="
275
275
  - !ruby/object:Gem::Version
276
- version: 0.4.5
276
+ version: 1.1.1
277
277
  - !ruby/object:Gem::Dependency
278
278
  name: ecoportal-api-v2
279
279
  requirement: !ruby/object:Gem::Requirement
280
280
  requirements:
281
281
  - - "~>"
282
282
  - !ruby/object:Gem::Version
283
- version: '2.0'
283
+ version: '3.1'
284
284
  - - ">="
285
285
  - !ruby/object:Gem::Version
286
- version: 2.0.16
286
+ version: 3.1.1
287
287
  type: :runtime
288
288
  prerelease: false
289
289
  version_requirements: !ruby/object:Gem::Requirement
290
290
  requirements:
291
291
  - - "~>"
292
292
  - !ruby/object:Gem::Version
293
- version: '2.0'
293
+ version: '3.1'
294
294
  - - ">="
295
295
  - !ruby/object:Gem::Version
296
- version: 2.0.16
296
+ version: 3.1.1
297
297
  - !ruby/object:Gem::Dependency
298
298
  name: ed25519
299
299
  requirement: !ruby/object:Gem::Requirement
@@ -559,14 +559,12 @@ files:
559
559
  - lib/eco-helpers.rb
560
560
  - lib/eco/api.rb
561
561
  - lib/eco/api/common.rb
562
- - lib/eco/api/common/class_auto_loader.rb
563
- - lib/eco/api/common/class_helpers.rb
564
- - lib/eco/api/common/class_hierarchy.rb
565
562
  - lib/eco/api/common/class_meta_basics.rb
566
563
  - lib/eco/api/common/loaders.rb
567
564
  - lib/eco/api/common/loaders/base.rb
568
565
  - lib/eco/api/common/loaders/case_base.rb
569
566
  - lib/eco/api/common/loaders/config.rb
567
+ - lib/eco/api/common/loaders/config/block.rb
570
568
  - lib/eco/api/common/loaders/config/cli.rb
571
569
  - lib/eco/api/common/loaders/config/session.rb
572
570
  - lib/eco/api/common/loaders/config/workflow.rb
@@ -886,7 +884,13 @@ files:
886
884
  - lib/eco/api/usecases/lib/error_handling.rb
887
885
  - lib/eco/api/usecases/lib/files.rb
888
886
  - lib/eco/api/usecases/lib/files/file_pattern.rb
887
+ - lib/eco/api/usecases/lib/files/input_file.rb
889
888
  - lib/eco/api/usecases/lib/files/sftp.rb
889
+ - lib/eco/api/usecases/lib/locations.rb
890
+ - lib/eco/api/usecases/lib/locations/base.rb
891
+ - lib/eco/api/usecases/lib/locations/mapping.rb
892
+ - lib/eco/api/usecases/lib/people.rb
893
+ - lib/eco/api/usecases/lib/people/base.rb
890
894
  - lib/eco/api/usecases/ooze_cases.rb
891
895
  - lib/eco/api/usecases/ooze_cases/export_register_case.rb
892
896
  - lib/eco/api/usecases/ooze_samples.rb
@@ -924,6 +928,7 @@ files:
924
928
  - lib/eco/api/usecases/use_case_chain/chaining.rb
925
929
  - lib/eco/api/usecases/use_case_io.rb
926
930
  - lib/eco/api/usecases/use_case_io/chain.rb
931
+ - lib/eco/api/usecases/workflow.rb
927
932
  - lib/eco/assets.rb
928
933
  - lib/eco/assets/language.rb
929
934
  - lib/eco/cli.rb
@@ -949,17 +954,31 @@ files:
949
954
  - lib/eco/cli_default/people_filters.rb
950
955
  - lib/eco/cli_default/usecases.rb
951
956
  - lib/eco/cli_default/workflow.rb
957
+ - lib/eco/cli_default/workflow/end.rb
958
+ - lib/eco/cli_default/workflow/launch_jobs.rb
959
+ - lib/eco/cli_default/workflow/load.rb
960
+ - lib/eco/cli_default/workflow/load/data.rb
961
+ - lib/eco/cli_default/workflow/load/input.rb
962
+ - lib/eco/cli_default/workflow/options.rb
963
+ - lib/eco/cli_default/workflow/post_launch.rb
964
+ - lib/eco/cli_default/workflow/report.rb
965
+ - lib/eco/cli_default/workflow/rescued_exception.rb
966
+ - lib/eco/cli_default/workflow/usecases.rb
952
967
  - lib/eco/common.rb
953
968
  - lib/eco/csv.rb
954
969
  - lib/eco/csv/split.rb
955
970
  - lib/eco/csv/stream.rb
956
971
  - lib/eco/csv/table.rb
957
972
  - lib/eco/data.rb
973
+ - lib/eco/data/count_trace.rb
958
974
  - lib/eco/data/files.rb
975
+ - lib/eco/data/files/content.rb
959
976
  - lib/eco/data/files/directory.rb
960
977
  - lib/eco/data/files/encoding.rb
961
978
  - lib/eco/data/files/file_pattern.rb
962
- - lib/eco/data/files/helpers.rb
979
+ - lib/eco/data/files/folder.rb
980
+ - lib/eco/data/files/relative_path.rb
981
+ - lib/eco/data/files/timestamp.rb
963
982
  - lib/eco/data/fuzzy_match.rb
964
983
  - lib/eco/data/fuzzy_match/array_helpers.rb
965
984
  - lib/eco/data/fuzzy_match/chars_position_score.rb
@@ -1021,24 +1040,29 @@ files:
1021
1040
  - lib/eco/language/hash_transform.rb
1022
1041
  - lib/eco/language/hash_transform_modifier.rb
1023
1042
  - lib/eco/language/klass.rb
1043
+ - lib/eco/language/klass/auto_loader.rb
1024
1044
  - lib/eco/language/klass/builder.rb
1045
+ - lib/eco/language/klass/const.rb
1025
1046
  - lib/eco/language/klass/helpers_built.rb
1026
1047
  - lib/eco/language/klass/hierarchy.rb
1027
1048
  - lib/eco/language/klass/inheritable_class_vars.rb
1028
1049
  - lib/eco/language/klass/naming.rb
1029
1050
  - lib/eco/language/klass/resolver.rb
1051
+ - lib/eco/language/klass/uid.rb
1030
1052
  - lib/eco/language/klass/when_inherited.rb
1031
1053
  - lib/eco/language/match.rb
1032
1054
  - lib/eco/language/match_modifier.rb
1033
1055
  - lib/eco/language/methods.rb
1056
+ - lib/eco/language/methods/access_modifier.rb
1034
1057
  - lib/eco/language/methods/call_detector.rb
1035
1058
  - lib/eco/language/methods/dsl_able.rb
1036
1059
  - lib/eco/language/methods/instance_method_helpers.rb
1037
1060
  - lib/eco/language/models.rb
1038
- - lib/eco/language/models/class_helpers.rb
1039
1061
  - lib/eco/language/models/collection.rb
1062
+ - lib/eco/language/models/hierarchy.rb
1040
1063
  - lib/eco/language/models/modifier.rb
1041
1064
  - lib/eco/language/models/parser_serializer.rb
1065
+ - lib/eco/language/models/workflow.rb
1042
1066
  - lib/eco/language/models/wrap.rb
1043
1067
  - lib/eco/language/strings.rb
1044
1068
  - lib/eco/language/strings/underscore.rb
@@ -1,114 +0,0 @@
1
- module Eco
2
- module API
3
- module Common
4
- # Helpers for dynamic object loading based on class declaration
5
- # @note
6
- # - this helpers aim to boost the usage of the ruby language in complex api configurations.
7
- module ClassAutoLoader
8
- include Eco::API::Common::ClassHelpers
9
-
10
- # To enable the class autoloader, you should use this method
11
- def autoloads_children_of(klass)
12
- class_resolver :autoloader_class, klass
13
- @autoloaded_class = klass
14
- end
15
-
16
- # Resolves the class `autoloader_class` if it has been defined via `autoloads_children_of`
17
- def autoloaded_class
18
- return nil unless @autoloaded_class
19
- autoloader_class
20
- end
21
-
22
- # To which restricted namespaces this class autoloads from
23
- def autoloaded_namespaces(type = :include)
24
- @autoloaded_namespaces ||= {}
25
- @autoloaded_namespaces[type] ||= []
26
- end
27
-
28
- # To restrict which namespaces it is allowed to load from
29
- def autoload_namespace(*namespaces)
30
- _autoload_namespace(:include, *namespaces)
31
- end
32
-
33
- # To ignore certain namespaces this class should not autoload from
34
- def autoload_namespace_ignore(*namespaces)
35
- _autoload_namespace(:ignore, *namespaces)
36
- end
37
-
38
- def _autoload_namespace(type, *namespaces)
39
- autoloaded_namespaces(type).concat(namespaces) unless namespaces.empty?
40
- end
41
-
42
- # @param constant [Class, String] a class or namespace we want to check auto-load entitlement thereof.
43
- # @return [Boolean] determines if a given namespace is entitled for autoloading
44
- def autoload_class?(constant)
45
- constants = "#{constant}".split("::").compact
46
- autoload = true
47
- unless autoloaded_namespaces(:include).empty?
48
- autoload = autoloaded_namespaces(:include).any? do |ns|
49
- "#{ns}".split("::").compact.zip(constants).all? {|(r, c)| r == c}
50
- end
51
- end
52
- unless autoloaded_namespaces(:ignore).empty?
53
- autoload &&= autoloaded_namespaces(:ignore).none? do |ns|
54
- "#{ns}".split("::").compact.zip(constants).all? {|(r, c)| r == c}
55
- end
56
- end
57
- autoload
58
- end
59
-
60
- # As children are loaded as they are declared, we should not load twice same children.
61
- def autoloaded_children
62
- @auto_loaded_children ||= []
63
- end
64
-
65
- # Children classes of `autoloader_class` that have not been created an instance of.
66
- def unloaded_children
67
- return [] unless autoloaded_class
68
- new_detected = new_classes
69
- known_class!(*new_detected)
70
- descendants(parent_class: autoloaded_class, scope: new_detected).select do |child_class|
71
- !autoloaded_children.include?(child_class) && autoload_class?(child_class)
72
- end.sort
73
- end
74
-
75
- # It loads/creates a new instance of children classes pending to be loaded.
76
- # @return [Boolean] `true` if there were children loaded, `false` otherwise.
77
- def autoload_children(object)
78
- return false if !autoloaded_class || @loading_children
79
- pending_children = unloaded_children
80
- return false if pending_children.empty?
81
- @loading_children = true
82
- pending_children.each do |klass|
83
- begin
84
- @child = klass.new(object)
85
- rescue TypeError => e
86
- # Can't create from this class (must be the singleton class)
87
- # Just ignore
88
- ensure
89
- autoloaded_children.push(klass)
90
- end
91
- end
92
- @loading_children = false
93
- true
94
- end
95
-
96
- # Known namespaces serves the purpose to discover recently added namespaces
97
- # provided that the namespace discovery is optimized
98
- def known_classes
99
- @known_classes ||= []
100
- end
101
-
102
- # Add to known namespaces
103
- def known_class!(*classes)
104
- known_classes.concat(classes)
105
- end
106
-
107
- # List all new namespaces
108
- def new_classes
109
- ObjectSpace.each_object(::Class).to_a - known_classes
110
- end
111
- end
112
- end
113
- end
114
- end