eco-helpers 3.0.37 → 3.1.1

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 (126) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +1 -0
  3. data/CHANGELOG.md +116 -1
  4. data/lib/eco/api/common/loaders/base.rb +2 -2
  5. data/lib/eco/api/common/loaders/case_base.rb +2 -0
  6. data/lib/eco/api/common/loaders/config/block.rb +78 -0
  7. data/lib/eco/api/common/loaders/config/workflow/mailer.rb +39 -7
  8. data/lib/eco/api/common/loaders/config.rb +3 -26
  9. data/lib/eco/api/common/loaders/error_handler.rb +2 -0
  10. data/lib/eco/api/common/loaders/parser.rb +1 -4
  11. data/lib/eco/api/common/people/entries.rb +23 -6
  12. data/lib/eco/api/common/people/entry_factory.rb +1 -1
  13. data/lib/eco/api/common/people/person_entry.rb +104 -27
  14. data/lib/eco/api/common/people/person_parser.rb +50 -16
  15. data/lib/eco/api/common/people/supervisor_helpers.rb +12 -6
  16. data/lib/eco/api/common/session/base_session.rb +75 -81
  17. data/lib/eco/api/common/session/environment.rb +49 -55
  18. data/lib/eco/api/common/session/file_manager.rb +132 -135
  19. data/lib/eco/api/common/session/helpers/prompt_user.rb +23 -30
  20. data/lib/eco/api/common/session/helpers.rb +10 -15
  21. data/lib/eco/api/common/session/logger/cache.rb +89 -96
  22. data/lib/eco/api/common/session/logger/channels.rb +24 -32
  23. data/lib/eco/api/common/session/logger/log.rb +38 -46
  24. data/lib/eco/api/common/session/logger.rb +50 -54
  25. data/lib/eco/api/common/session/mailer/aws_provider.rb +63 -71
  26. data/lib/eco/api/common/session/mailer/provider_base.rb +43 -48
  27. data/lib/eco/api/common/session/mailer/sendgrid_provider.rb +101 -109
  28. data/lib/eco/api/common/session/mailer.rb +78 -83
  29. data/lib/eco/api/common/session/s3_uploader.rb +132 -138
  30. data/lib/eco/api/common/session/sftp.rb +202 -208
  31. data/lib/eco/api/common.rb +0 -3
  32. data/lib/eco/api/custom/mailer.rb +4 -2
  33. data/lib/eco/api/error/handlers.rb +1 -1
  34. data/lib/eco/api/microcases/people/apply_changes/set_core/core_excluded.rb +8 -2
  35. data/lib/eco/api/microcases/people/manage/search.rb +1 -1
  36. data/lib/eco/api/organization/people/similarity.rb +3 -3
  37. data/lib/eco/api/session/batch/base_policy.rb +42 -27
  38. data/lib/eco/api/session/batch/launcher/mode_size.rb +6 -1
  39. data/lib/eco/api/session/batch/launcher.rb +16 -3
  40. data/lib/eco/api/session/config/api.rb +4 -3
  41. data/lib/eco/api/session/config/apis/one_off.rb +1 -1
  42. data/lib/eco/api/session/config/files.rb +13 -12
  43. data/lib/eco/api/session/config/workflow.rb +1 -373
  44. data/lib/eco/api/session/config.rb +30 -9
  45. data/lib/eco/api/usecases/base_case/model.rb +6 -6
  46. data/lib/eco/api/usecases/base_case.rb +1 -1
  47. data/lib/eco/api/usecases/cli.rb +1 -1
  48. data/lib/eco/api/usecases/default/locations/tagtree_extract_case.rb +8 -9
  49. data/lib/eco/api/usecases/default_cases/to_csv_case.rb +4 -1
  50. data/lib/eco/api/usecases/graphql/samples/location/command/dsl.rb +2 -2
  51. data/lib/eco/api/usecases/lib/base/env.rb +21 -23
  52. data/lib/eco/api/usecases/lib/files/file_pattern.rb +41 -14
  53. data/lib/eco/api/usecases/lib/files/input_file.rb +110 -0
  54. data/lib/eco/api/usecases/lib/files/sftp.rb +5 -2
  55. data/lib/eco/api/usecases/lib/files.rb +1 -0
  56. data/lib/eco/api/usecases/lib/locations/base.rb +23 -0
  57. data/lib/eco/api/usecases/lib/locations/mapping.rb +94 -0
  58. data/lib/eco/api/usecases/lib/locations.rb +7 -0
  59. data/lib/eco/api/usecases/lib/people/base.rb +20 -0
  60. data/lib/eco/api/usecases/lib/people.rb +6 -0
  61. data/lib/eco/api/usecases/lib.rb +2 -0
  62. data/lib/eco/api/usecases/ooze_cases.rb +1 -1
  63. data/lib/eco/api/usecases/ooze_samples/register_export_case.rb +1 -0
  64. data/lib/eco/api/usecases/ooze_samples/register_update_case.rb +1 -0
  65. data/lib/eco/api/usecases/samples/drivers/sftp_sample.rb +2 -0
  66. data/lib/eco/api/usecases/samples/drivers/url_pull_sample.rb +8 -2
  67. data/lib/eco/api/usecases/service/sftp/with_target_config.rb +0 -33
  68. data/lib/eco/api/usecases/service/sftp.rb +7 -1
  69. data/lib/eco/api/usecases/use_case.rb +3 -2
  70. data/lib/eco/api/usecases/workflow.rb +5 -0
  71. data/lib/eco/api/usecases.rb +12 -5
  72. data/lib/eco/cli/scripting/args_helpers.rb +1 -9
  73. data/lib/eco/cli_default/options.rb +98 -68
  74. data/lib/eco/cli_default/workflow/end.rb +22 -0
  75. data/lib/eco/cli_default/workflow/launch_jobs.rb +14 -0
  76. data/lib/eco/cli_default/workflow/load/data.rb +27 -0
  77. data/lib/eco/cli_default/workflow/load/input.rb +28 -0
  78. data/lib/eco/cli_default/workflow/load.rb +13 -0
  79. data/lib/eco/cli_default/workflow/options.rb +10 -0
  80. data/lib/eco/cli_default/workflow/post_launch.rb +65 -0
  81. data/lib/eco/cli_default/workflow/report.rb +17 -0
  82. data/lib/eco/cli_default/workflow/rescued_exception.rb +21 -0
  83. data/lib/eco/cli_default/workflow/usecases.rb +23 -0
  84. data/lib/eco/cli_default/workflow.rb +24 -180
  85. data/lib/eco/data/count_trace.rb +51 -0
  86. data/lib/eco/data/files/content.rb +39 -0
  87. data/lib/eco/data/files/directory.rb +78 -45
  88. data/lib/eco/data/files/encoding.rb +12 -21
  89. data/lib/eco/data/files/file_pattern.rb +15 -8
  90. data/lib/eco/data/files/folder.rb +196 -0
  91. data/lib/eco/data/files/relative_path.rb +54 -0
  92. data/lib/eco/data/files/timestamp.rb +18 -0
  93. data/lib/eco/data/files.rb +46 -5
  94. data/lib/eco/data/fuzzy_match.rb +1 -1
  95. data/lib/eco/data/hashes/array_diff.rb +11 -5
  96. data/lib/eco/data/hashes/diff_result/meta.rb +12 -4
  97. data/lib/eco/data/locations/node_diff/accessors.rb +1 -1
  98. data/lib/eco/data/mapper.rb +5 -1
  99. data/lib/eco/data.rb +1 -0
  100. data/lib/eco/language/delegation/delegating_missing.rb +1 -1
  101. data/lib/eco/language/delegation/delegating_missing_const.rb +1 -1
  102. data/lib/eco/language/delegation/delegating_missing_on_class.rb +1 -1
  103. data/lib/eco/language/delegation/for_delegator/delegated_class.rb +1 -1
  104. data/lib/eco/language/klass/auto_loader.rb +129 -0
  105. data/lib/eco/language/klass/builder.rb +6 -6
  106. data/lib/eco/language/klass/const.rb +19 -0
  107. data/lib/eco/language/klass/helpers_built.rb +3 -1
  108. data/lib/eco/language/klass/hierarchy.rb +5 -1
  109. data/lib/eco/language/klass/naming.rb +5 -2
  110. data/lib/eco/language/klass/resolver.rb +21 -6
  111. data/lib/eco/language/klass/uid.rb +12 -0
  112. data/lib/eco/language/klass/when_inherited.rb +30 -6
  113. data/lib/eco/language/klass.rb +5 -2
  114. data/lib/eco/language/methods/access_modifier.rb +23 -0
  115. data/lib/eco/language/methods/instance_method_helpers.rb +6 -1
  116. data/lib/eco/language/methods.rb +1 -0
  117. data/lib/eco/language/models/hierarchy.rb +41 -0
  118. data/lib/eco/language/models/workflow.rb +385 -0
  119. data/lib/eco/language/models.rb +2 -1
  120. data/lib/eco/version.rb +1 -1
  121. metadata +31 -7
  122. data/lib/eco/api/common/class_auto_loader.rb +0 -114
  123. data/lib/eco/api/common/class_helpers.rb +0 -9
  124. data/lib/eco/api/common/class_hierarchy.rb +0 -45
  125. data/lib/eco/data/files/helpers.rb +0 -152
  126. data/lib/eco/language/models/class_helpers.rb +0 -136
@@ -0,0 +1,385 @@
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)
24
+ class_name = to_constant(key.to_s)
25
+
26
+ new_class(
27
+ class_name,
28
+ inherits: Eco::API::Session::Config::Workflow
29
+ ) do |klass|
30
+ klass.model = model[key]
31
+ end
32
+ end
33
+ end
34
+
35
+ attr_reader :config
36
+
37
+ def initialize(name = nil, config:, _parent: self) # rubocop:disable Lint/UnderscorePrefixedVariableName
38
+ @config = config
39
+ @name = name
40
+
41
+ @stages = {}
42
+ @_parent = _parent
43
+
44
+ @pending = true
45
+ # moments
46
+ @on = nil
47
+ @before = []
48
+ @after = []
49
+ end
50
+
51
+ def name(with_path: false)
52
+ return @name if !with_path || root?
53
+
54
+ [@_parent.name(with_path: true), @name].compact.join('.')
55
+ end
56
+
57
+ # Has this stage run yet?
58
+ # @note it does **not** include _sub-stages_ that run `before`
59
+ # @return [Boolean] `true` if it has run, `false` otherwise
60
+ def pending?
61
+ @pending
62
+ end
63
+
64
+ # Do not run this stage!
65
+ def skip!
66
+ @skip = true
67
+ @pending = false
68
+ end
69
+
70
+ # Has this stage been marked as to be skipped
71
+ # @return [Boolean] depends on this order:
72
+ # - `true` if `skip!` was called
73
+ # - `false` if the current _stage_ is `root?` (the top stage of the hierarchy)
74
+ # - `true` if its parent task is to be skipped
75
+ def skip?
76
+ return @skip if instance_variable_defined?(:@skip)
77
+ return false if root?
78
+
79
+ @_parent.skip?
80
+ end
81
+
82
+ # Used in **configuration** time **to configure** the _workflow_ of the target (sub)stage `key`
83
+ # @note
84
+ # 1. if a `block` is provided it will `yield` the target stage immediately
85
+ # 2. a `block` is only required when `key` has not been specified.
86
+ # @param key [Symbol, nil] cases:
87
+ # - if `key` is not provided, it targets the _current stage_
88
+ # - if `key` is provided, it targets the specific _sub-stage_
89
+ # @yield [stage_workflow] further _workflow_ configuration `for` the target stage `key`
90
+ # @yieldparam stage_workflow [Eco::API::Session::Config::Workflow] the _target stage_ referred by `key`
91
+ # @return [Eco::API::Session::Config::Workflow]
92
+ # 1. if block is provided provided, it returns the **current stage** object (to ease chainig).
93
+ # 2. if block is not provided, it returns the **stage** referred by `key`
94
+ def for(key = nil, &block)
95
+ msg = "With no 'key', a block should be given."
96
+ raise ArgumentError, msg unless key || block_given?
97
+
98
+ tap do
99
+ next yield(self) unless key
100
+ next stage(key).for(&block) if block_given?
101
+
102
+ return stage(key)
103
+ end
104
+ end
105
+ alias_method :with, :for
106
+
107
+ # Used in **configuration** time **to define** the **behaviour** the target (sub)stage `key`
108
+ # @note if a `block` is provided it will **not** `yield` the target stage immediately,
109
+ # but when the _workflow_ reaches the stage
110
+ # @param key [Symbol, nil] cases:
111
+ # - if `key` is not provided, it targets the _current stage_
112
+ # - if `key` is provided, it targets the specific _sub-stage_
113
+ # @yield [stage_workflow, io] the behaviour of the target stage `key` when the _workflow_ reaches it
114
+ # @yieldparam stage_workflow [Eco::API::Session::Config::Workflow] the _target stage_ referred by `key`
115
+ # @yieldparam io [INPUT_OUTPUT_CLASS] the input/output object carried througout all the _workflow_
116
+ # @yieldreturn [INPUT_OUTPUT_CLASS] the `io` input/output object carried througout all the _workflow_
117
+ # @return [Eco::API::Session::Config::Workflow] the current stage object (to ease chainig).
118
+ def on(key = nil, &block)
119
+ msg = 'A block should be given.'
120
+ raise ArgumentError, msg unless block_given?
121
+
122
+ if key
123
+ stage(key).on(&block)
124
+ else
125
+ @on = block
126
+ end
127
+
128
+ self
129
+ end
130
+
131
+ # When there is an `Exception`, you might have defined some `callback`
132
+ # to do something with it (i.e. register, email)
133
+ # @yield [exception, io] the `callback` to do something with
134
+ # an `Exception` raised within this _workflow_ stage
135
+ # @yieldparam exception [Exception] the exception object that was raised
136
+ # @yieldparam io [INPUT_OUTPUT_CLASS] the input/output object carried througout all the _workflow_
137
+ # @yieldreturn [INPUT_OUTPUT_CLASS] the `io` input/output object carried througout all the _workflow_
138
+ # @return [Eco::API::Session::Config::Workflow] the current stage object (to ease chainig).
139
+ def rescue(&block)
140
+ return @rescue unless block_given?
141
+
142
+ @rescue = block
143
+ self
144
+ end
145
+ # Prevent reserved word clash on DSL
146
+ alias_method :exception, :rescue
147
+
148
+ # Called on `SystemExit` exception
149
+ def exit_handle(&block)
150
+ return @exit_handle unless block_given?
151
+
152
+ @exit_handle = block
153
+ self
154
+ end
155
+
156
+ # Used in **configuration** time **add previous** `callbacks`
157
+ # **before** the `on` _callback_ of the (sub)stage `key` is actually `run`
158
+ # @note
159
+ # - it will **not** `yield` it immediately, but when the _workflow_ reaches the target stage
160
+ # - in this case, you can define multiple `callbacks`
161
+ # @param key [Symbol, nil] cases:
162
+ # - if `key` is not provided, it targets the _current stage_
163
+ # - if `key` is provided, it targets the specific _sub-stage_
164
+ # @yield [stage_workflow, io] one of the things to do **before** the
165
+ # `on` _callback_ of the (sub)stage `key` is actually `run`
166
+ # @yieldparam stage_workflow [Eco::API::Session::Config::Workflow] the _target stage_ referred by `key`
167
+ # @yieldparam io [INPUT_OUTPUT_CLASS] the input/output object carried througout all the _workflow_
168
+ # @yieldreturn [INPUT_OUTPUT_CLASS] `io` the input/output object carried througout all the _workflow_
169
+ # @return [Eco::API::Session::Config::Workflow] the current stage object (to ease chainig).
170
+ def before(key = nil, &block)
171
+ msg = 'A block should be given.'
172
+ raise ArgumentError, msg unless block_given?
173
+
174
+ if key
175
+ stage(key).before(&block)
176
+ else
177
+ @before.push(block)
178
+ end
179
+
180
+ self
181
+ end
182
+
183
+ # Used in **configuration** time **add previous** `callbacks` **after** the `on` _callback_
184
+ # of the (sub)stage `key` is actually `run`
185
+ # @note
186
+ # - it will **not** `yield` it immediately, but when the _workflow_ reaches the target stage
187
+ # - in this case, you can define multiple `callbacks`
188
+ # @param key [Symbol, nil] cases:
189
+ # - if `key` is not provided, it targets the _current stage_
190
+ # - if `key` is provided, it targets the specific _sub-stage_
191
+ # @yield [stage_workflow, io] one of the things to do **after** the
192
+ # `on` _callback_ of the (sub)stage `key` is actually `run`
193
+ # @yieldparam stage_workflow [Eco::API::Session::Config::Workflow] the _target stage_ referred by `key`
194
+ # @yieldparam io [INPUT_OUTPUT_CLASS] the input/output object carried througout all the _workflow_
195
+ # @yieldreturn [INPUT_OUTPUT_CLASS] `io` the input/output object carried througout all the _workflow_
196
+ # @return [Eco::API::Session::Config::Workflow] the current stage object (to ease chainig).
197
+ def after(key = nil, &block)
198
+ msg = 'A block should be given.'
199
+ raise ArgumentError, msg unless block_given?
200
+
201
+ if key
202
+ stage(key).after(&block)
203
+ else
204
+ @after.push(block)
205
+ end
206
+
207
+ self
208
+ end
209
+
210
+ # Used in run time to **execute the workflow** of the (sub)stage `key`
211
+ # @note if a `block` is **not** provided:
212
+ # - it will run the `before` _callbacks_ defined during the configuration time
213
+ # - it will run the _workflow_ of any defined _**substage**_ of the `key` stage
214
+ # - it will run the `on` _callback_ defined during the configuration time
215
+ # - it will mark the stage as **not** `pending?`.
216
+ # - it will run the `after` _callbacks_ defined during the configuration time
217
+ # @note if a `block` is provided:
218
+ # - it will **not** run the workflow of the substages to `key` stage
219
+ # - it will **not** run the `callback` for `on` defined during the configuration time
220
+ # - it will rather `yield` the target stage after all the `before` _callbacks_ have been run
221
+ # - aside of this, the rest will be the same as when the _block_ is provided (see previous note)
222
+ # @note [if the object returned by `before`, `after` and `run` callbacks
223
+ # is not an `INPUT_OUTPUT_CLASS`, the original `io` object will be returned instead.
224
+ # @param key [Symbol, nil] cases:
225
+ # - if `key` is not provided, it targets the _current stage_
226
+ # - if `key` is provided, it targets the specific _sub-stage_
227
+ # @param io [INPUT_OUTPUT_CLASS] the input/output object
228
+ # @yield [stage_workflow, io] if a `block` is provided, see `note`
229
+ # @yieldparam stage_workflow [Eco::API::Session::Config::Workflow] the _target stage_ referred by `key`
230
+ # @yieldparam io [INPUT_OUTPUT_CLASS] the input/output object carried througout all the _workflow_
231
+ # @yieldreturn [INPUT_OUTPUT_CLASS] the `io` input/output object carried througout all the _workflow_
232
+ # @return [Eco::API::Session::Config::Workflow] the current stage object (to ease chainig).
233
+ def run(key = nil, io:, &block)
234
+ raise 'Missing BaseIO object' unless io.is_a?(input_output_class)
235
+
236
+ rescuable(io) do
237
+ if key
238
+ io = io_result(io: io) do
239
+ stage(key).run(io: io, &block)
240
+ end
241
+ elsif pending?
242
+ io = run_before(io)
243
+ io = run_it(io, &block) unless skip?
244
+ io = run_after(io)
245
+ end
246
+ io
247
+ ensure
248
+ @pending = false
249
+ end
250
+ end
251
+
252
+ protected
253
+
254
+ def root?
255
+ @_parent == self
256
+ end
257
+
258
+ def path
259
+ return name if root?
260
+
261
+ "#{@_parent.path}:#{name}"
262
+ end
263
+
264
+ def ready?
265
+ !!@on
266
+ end
267
+
268
+ def run_before(io)
269
+ @before.each do |c|
270
+ io = io_result(io: io) do
271
+ io.evaluate(self, io, &c)
272
+ end
273
+ end
274
+
275
+ io
276
+ end
277
+
278
+ def run_after(io)
279
+ @after.each do |c|
280
+ io = io_result(io: io) do
281
+ io.evaluate(self, io, &c)
282
+ end
283
+ end
284
+
285
+ io
286
+ end
287
+
288
+ def run_it(io, &block)
289
+ io.session.log(:debug) {
290
+ "(Workflow: #{path}) running now"
291
+ }
292
+
293
+ if block
294
+ io = io_result(io: io) do
295
+ io.evaluate(self, io, &block)
296
+ end
297
+ else
298
+ existing_stages.each do |stg|
299
+ io = io_result(io: io) do
300
+ stg.run(io: io)
301
+ end
302
+ end
303
+
304
+ unless ready?
305
+ io.session.log(:debug) {
306
+ "(Workflow: #{path}) 'on' callback is not defined, nor block given"
307
+ }
308
+ end
309
+
310
+ io = io_result(io: io) do
311
+ io.evaluate(self, io, &@on)
312
+ end
313
+ end
314
+
315
+ io
316
+ ensure
317
+ @pending = false
318
+ end
319
+
320
+ # It ensures an `INPUT_OUTPUT_CLASS` is returned
321
+ # @note it always brings the IO to be a `BaseIO`.
322
+ # As the `output` and the type is captured, it just cleans usecase related
323
+ # logic from the object.
324
+ # @raise ArgumentError if `klass` isn't child of `INPUT_OUTPUT_CLASS`
325
+ # @return [INPUT_OUTPUT_CLASS] the `io` input/output object carried througout the _workflow_
326
+ def io_result(io:, klass: input_output_class)
327
+ msg = "Expecting class to be child of #{input_output_class}. Given: #{klass}"
328
+ raise ErrorArgument, msg unless klass <= input_output_class
329
+
330
+ result = yield
331
+ io = result if result.is_a?(klass)
332
+ io.instance_of?(klass) ? io : io.base
333
+ end
334
+
335
+ def existing_stages
336
+ # sort defined stages by stage order
337
+ sorted_keys = self.class.stages & @stages.keys
338
+ sorted_keys.map {|k| stage(k)}
339
+ end
340
+
341
+ def ready_stages
342
+ exiting_stages.select(&:ready?)
343
+ end
344
+
345
+ def stages_ready?
346
+ existing_stages.all?(&:ready?)
347
+ end
348
+
349
+ def stage(key)
350
+ self.class.validate_stage!(key)
351
+ @stages[key] ||= self.class.workflow_class(key).new(
352
+ key,
353
+ _parent: self,
354
+ config: config
355
+ )
356
+ end
357
+
358
+ def input_output_class
359
+ self.class::INPUT_OUTPUT_CLASS
360
+ end
361
+
362
+ # helper to treat trigger the exit and rescue handlers
363
+ def rescuable(io)
364
+ yield
365
+ # rescue SystemStackError => err
366
+ # puts err.patch_full_message(trace_count: 100)
367
+ # exit 1
368
+ rescue SystemExit => err
369
+ io = io_result(io: io) do
370
+ io.evaluate(err, io, &exit_handle)
371
+ end
372
+
373
+ exit err.status
374
+ rescue Interrupt => _int
375
+ raise
376
+ rescue StandardError => err
377
+ # raise unless self.rescue
378
+ io = io_result(io: io) do
379
+ io.evaluate(err, io, &self.rescue)
380
+ end
381
+
382
+ raise
383
+ end
384
+ end
385
+ 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.1'.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.1
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-04-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: byebug
@@ -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
@@ -1,9 +0,0 @@
1
- module Eco
2
- module API
3
- module Common
4
- module ClassHelpers
5
- include Eco::Language::Klass::HelpersBuilt
6
- end
7
- end
8
- end
9
- end
@@ -1,45 +0,0 @@
1
- module Eco
2
- module API
3
- module Common
4
- # Helpers for dynammic generation of classes based on a hierarchical model
5
- # @attr_reader model [Hash, nil] the `model` of the current `class`
6
- module ClassHierarchy
7
- include Eco::API::Common::ClassHelpers
8
-
9
- attr_reader :model
10
-
11
- # @param value [Hash, Enumerable, String, Symbol, nil] unparsed model to be assigned to the `class`
12
- def model=(value)
13
- @model = parse_model(value)
14
- end
15
-
16
- # @return [Array<String>] the `keys` of the current class' `model`
17
- def model_attrs
18
- model&.keys || []
19
- end
20
-
21
- # Thanks to this step the format on the declaration of the model is flexible
22
- # @param model [Hash, Enumerable, String, Symbol, nil]
23
- # @return [Hash, nil] where keys are `Symbol` s
24
- def parse_model(model)
25
- case model
26
- when String
27
- parse_model(model.to_sym)
28
- when Symbol
29
- {model => nil}
30
- when Hash
31
- model.transform_keys(&:to_sym)
32
- when Enumerable
33
- model.each_with_object({}) do |sub, hash|
34
- hash.merge!(parse_model(sub))
35
- end
36
- when NilClass
37
- nil
38
- else
39
- raise "Incorrect model declaration, allowed String, Symbol, Hash and Enumerable. Given: #{model.class}"
40
- end
41
- end
42
- end
43
- end
44
- end
45
- end