eco-helpers 3.1.2 → 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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ab6e025cd47d9c9afb95fb6a311307141febeb6d518d500efa0a821f02c2d917
4
- data.tar.gz: c66c7648b57210a687f1cd87cf864707e0486ee7ea7d7f68d7882ab6399a10f1
3
+ metadata.gz: 75b6d72678a1efcda647811efab5d3271ef9aeab09fe0e615f676849bcf3e778
4
+ data.tar.gz: 935421753b4ec2b08f88e9fe786652b3da0fafaaa64ce9251531bccad73431ef
5
5
  SHA512:
6
- metadata.gz: b0cd9971a814d6e580e1d96cb902ce7d4f2e03adf2f79c63252a50e28f56824d8ff03ef1671e8f64db3d15bc13d7d5c7390301230b6f225e7e16f4bf73563f4b
7
- data.tar.gz: 6063ded8c5851cb7e01b464828eed8f92b2f213c9c1dcd6f80a4fbd8d3d687632de8a0007d0a466b6c2b72b6b2053e996eab8bbc8a8ae5f90567cb385b69c185
6
+ metadata.gz: 5c1ddf191f0e744aeb67235e74075c410cfdb4644d8061a768889c6f04bf3e89732f5adc37b2086ed166a64a0483d51d786e1d6c63131bedd3731312d852d86a
7
+ data.tar.gz: 7c0e5730bb34d18f1bc04fd2e17c470b7ff0d8a2e9c7b7398bae9385528fcafdf545a64f9c924c5f3b613fa08234359f5379feac10ebd214377948cb6d687690
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.1.3] - 2025-05-xx
5
+ ## [3.1.4] - 2025-05-xx
6
6
 
7
7
  ### Added
8
8
 
@@ -10,6 +10,22 @@ All notable changes to this project will be documented in this file.
10
10
 
11
11
  ### Fixed
12
12
 
13
+ ## [3.1.3] - 2025-05-14
14
+
15
+ ### Changed
16
+
17
+ - upgraded `ecoportal-api-v2` and `ecoportal-api-graphql`
18
+
19
+ ### Fixed
20
+
21
+ - `Eco::Language::Models::Workflow`
22
+ 1. `::workflow_class`: prevent `class_name` collision.
23
+ 2. Ensure `class_name` is representative of the stage's `name` and `path`.
24
+ - `Eco::Language::Models::Workflow`
25
+ - **Overriding** `#clone` and `#dup` methods
26
+ - **Fixes** `Eco::API::Session::Config#clone`, called when the `session` is swapped from the `:general` to the one of the target environment.
27
+ - `inheritable_class_vars` should join (uniq)
28
+
13
29
  ## [3.1.2] - 2025-05-05
14
30
 
15
31
  ### Added
data/eco-helpers.gemspec CHANGED
@@ -42,8 +42,8 @@ Gem::Specification.new do |spec|
42
42
  spec.add_dependency 'docx', '>= 0.8.0', '< 0.9'
43
43
  spec.add_dependency 'dotenv', '~> 3'
44
44
  spec.add_dependency 'ecoportal-api', '~> 0.10', '>= 0.10.10'
45
- spec.add_dependency 'ecoportal-api-graphql', '~> 0.4', '>= 0.4.5'
46
- spec.add_dependency 'ecoportal-api-v2', '~> 2.0', '>= 2.0.16'
45
+ spec.add_dependency 'ecoportal-api-graphql', '~> 1.1', '>= 1.1.1'
46
+ spec.add_dependency 'ecoportal-api-v2', '~> 3.1', '>= 3.1.1'
47
47
  spec.add_dependency 'ed25519', '~> 1.2'
48
48
  spec.add_dependency 'fast_excel', '>= 0.5.0', '< 0.6'
49
49
  spec.add_dependency 'fuzzy_match', '>= 2.1.0', '< 2.2'
@@ -7,8 +7,6 @@ class Eco::API::Common::Loaders::Workflow::Mailer < Eco::API::Common::Loaders::W
7
7
  travis@ecoportal.co.nz
8
8
  ].freeze
9
9
 
10
- inheritable_class_vars :config_block
11
-
12
10
  # @todo different emailing, depending on case type and/or preference
13
11
  config_block do
14
12
  #puts "running from class #{self}"
@@ -458,7 +458,8 @@ module Eco
458
458
 
459
459
  # @return [Eco::API::Session::Config::Workflow]
460
460
  def workflow
461
- @workflow = self['workflow'] ||= Eco::API::Session::Config::Workflow.new(config: self)
461
+ @workflow = self['workflow'] ||=
462
+ Eco::API::Session::Config::Workflow.new(config: self)
462
463
  @workflow.tap do |wf|
463
464
  yield(wf) if block_given?
464
465
  end
@@ -2,15 +2,15 @@ class Eco::CliDefault::Workflow
2
2
  class Report < Eco::API::Common::Loaders::Workflow
3
3
  config_block(:workflow, :report) do
4
4
  on(:report) do |_wf_rep, io|
5
- if (file = options.dig(:report, :people, :csv))
6
- options.deep_merge!(export: {
7
- options: {internal_names: true, nice_header: true, split_schemas: true},
8
- file: {name: file, format: :csv}
9
- })
5
+ next unless (file = options.dig(:report, :people, :csv))
10
6
 
11
- aux_io = io.new(data: data.updated_or_created)
12
- session.process_case('to-csv', io: aux_io, type: :export)
13
- end
7
+ options.deep_merge!(export: {
8
+ options: {internal_names: true, nice_header: true, split_schemas: true},
9
+ file: {name: file, format: :csv}
10
+ })
11
+
12
+ aux_io = io.new(data: data.updated_or_created)
13
+ session.process_case('to-csv', io: aux_io, type: :export)
14
14
  end
15
15
  end
16
16
  end
@@ -31,7 +31,10 @@ class Eco::CliDefault::Workflow < Eco::API::Common::Loaders::Workflow
31
31
  Report,
32
32
  End
33
33
  ].each do |wf_config|
34
- wf_config.config_copy(to: self, all: true)
34
+ wf_config.config_copy(
35
+ to: self,
36
+ all: true
37
+ )
35
38
  end
36
39
 
37
40
  config_apply!(all: true)
@@ -5,22 +5,25 @@ module Eco::Language::Klass
5
5
  # Keeps track on class instance variables that should be inherited by child classes.
6
6
  # @note
7
7
  # - subclasses will inherit the value as is at that moment
8
- # - any change afterwards will be only on the specific class (in line with class instance variables)
8
+ # - any change afterwards will be only on the specific class
9
+ # (in line with class instance variables)
9
10
  # - adapted from https://stackoverflow.com/a/10729812/4352306
10
- # TODO: this separates the logic of the method to the instance var.
11
+ # @todo this separates the logic of the method to the instance var.
11
12
  # Think if would be possible to join them somehow.
12
13
  def inheritable_class_vars(*vars)
13
14
  @inheritable_class_vars ||= [:inheritable_class_vars]
14
- @inheritable_class_vars += vars
15
+ @inheritable_class_vars |= vars
15
16
  end
16
17
 
17
18
  # Builds the attr_reader and attr_writer of `attrs` and registers
18
19
  # the associated instance variable as inheritable.
19
20
  def inheritable_attrs(*attrs)
20
21
  attrs.each do |attr|
21
- class_eval %(
22
- class << self; attr_accessor :#{attr} end
23
- ), __FILE__, __LINE__ - 2
22
+ class_eval <<-DEF_CLSS_ATTR, __FILE__, __LINE__ + 1
23
+ class << self # class << self
24
+ attr_accessor :#{attr} # attr_accessor :coolio
25
+ end # end
26
+ DEF_CLSS_ATTR
24
27
  end
25
28
 
26
29
  inheritable_class_vars(*attrs)
@@ -20,8 +20,10 @@ module Eco::Language::Models
20
20
  raise ArgumentError, msg
21
21
  end
22
22
 
23
- def workflow_class(key)
24
- class_name = to_constant(key.to_s)
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)
25
27
 
26
28
  new_class(
27
29
  class_name,
@@ -36,7 +38,7 @@ module Eco::Language::Models
36
38
 
37
39
  def initialize(name = nil, config:, _parent: self) # rubocop:disable Lint/UnderscorePrefixedVariableName
38
40
  @config = config
39
- @name = name
41
+ @name = name || 'root'
40
42
 
41
43
  @stages = {}
42
44
  @_parent = _parent
@@ -48,6 +50,12 @@ module Eco::Language::Models
48
50
  @after = []
49
51
  end
50
52
 
53
+ # We don't support cloning
54
+ def clone
55
+ self
56
+ end
57
+ alias_method :dup, :clone
58
+
51
59
  def name(with_path: false)
52
60
  return @name if !with_path || root?
53
61
 
@@ -243,6 +251,7 @@ module Eco::Language::Models
243
251
  io = run_it(io, &block) unless skip?
244
252
  io = run_after(io)
245
253
  end
254
+
246
255
  io
247
256
  ensure
248
257
  @pending = false
@@ -266,6 +275,10 @@ module Eco::Language::Models
266
275
  end
267
276
 
268
277
  def run_before(io)
278
+ io.session.log(:debug) {
279
+ "(Workflow: #{path}) running before callbacks..."
280
+ }
281
+
269
282
  @before.each do |c|
270
283
  io = io_result(io: io) do
271
284
  io.evaluate(self, io, &c)
@@ -276,6 +289,10 @@ module Eco::Language::Models
276
289
  end
277
290
 
278
291
  def run_after(io)
292
+ io.session.log(:debug) {
293
+ "(Workflow: #{path}) ...running after callbacks"
294
+ }
295
+
279
296
  @after.each do |c|
280
297
  io = io_result(io: io) do
281
298
  io.evaluate(self, io, &c)
@@ -348,7 +365,9 @@ module Eco::Language::Models
348
365
 
349
366
  def stage(key)
350
367
  self.class.validate_stage!(key)
351
- @stages[key] ||= self.class.workflow_class(key).new(
368
+ prefix = path.gsub(':', '::')
369
+
370
+ @stages[key] ||= self.class.workflow_class(key, prefix: prefix).new(
352
371
  key,
353
372
  _parent: self,
354
373
  config: config
data/lib/eco/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Eco
2
- VERSION = '3.1.2'.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.1.2
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-05-05 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