eco-helpers 1.5.7 → 1.5.8

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: 7620c9cd737d1ba284868030b84b2589b0cd55c71708fee487c79dbce3fa3313
4
- data.tar.gz: 444174de9c8634744060d411dcbad7229ef6c2acf24065f001ff29ecd41c6d4c
3
+ metadata.gz: 2b5a4fcfab321e9a7071a18fb52c38c21a67314a44a2edda63f4783de6ea9f38
4
+ data.tar.gz: 20b067294c6e2d47c6efa09c62052d2081ce3a56252216fb11c9e465ed0fc5af
5
5
  SHA512:
6
- metadata.gz: ae26e27d3b51f2b11cc50f6a6c6acc6229172b6a0416ca6feb633727b7fb45c9f19307d8d355ea14f77a67a041cf6886b54299f555b45990ff2c16ff6857f130
7
- data.tar.gz: a11ca5b39ca0067c912b2ae59b5bfff1f59caa8ee23565b91f3dc8d694c966cc593a9efb5b7ca1c9c53cae4855f6fa4e59c3a792c6068c5179637641f22a5300
6
+ metadata.gz: 92bc7a1814a8654bc9831ca8e763802ad40f0679c7ee31bc26b2146f7006744b576fa7586c16b2bd50deb1b74738c41d08d14e47b41fd3d34fd299d753213bb1
7
+ data.tar.gz: 1dbdacf348a3ec57718dbf15dc825adf97839ea070ae0463b4df1a8a020c3c8bee8edc5b3903029d57f112a8517f20ac0870a5b73a206257be21d27e425c66f2
@@ -1,6 +1,15 @@
1
1
  # Change Log
2
2
  All notable changes to this project will be documented in this file.
3
3
 
4
+ ## [1.5.8] - 2020-12-xx
5
+
6
+ ### Added
7
+ ### Changed
8
+ ### Fixed
9
+ - `Eco::API::Session::Batch::Jobs#job` shouldn't be calling the post-launch callback function on creation.
10
+ - `Eco::API::Session#new_job` should include a `&block` parameter.
11
+ - `Eco::API::UseCases::DefaultCases::RefreshCase`: fixed typo
12
+
4
13
  ## [1.5.7] - 2020-12-17
5
14
 
6
15
  ### Added
@@ -217,6 +217,7 @@ module Eco
217
217
  @job_groups ||= Batch::JobsGroups.new(enviro)
218
218
  end
219
219
 
220
+ # It retrives the group of `Batch::Jobs` named `name`. It creates it if it doesn't exist.
220
221
  # @return [Eco::API::Session::Batch::Jobs]
221
222
  def job_group(name, order: :last)
222
223
  case
@@ -228,9 +229,10 @@ module Eco
228
229
  end
229
230
 
230
231
  # Shortcut to create a job of certain type within a group
232
+ # @param [see @Eco::API::Session::Batch::Jobs#new]
231
233
  # @return [Eco::API::Session::Batch::Job]
232
- def new_job(group, name, type, usecase, sets = [:core, :details, :account])
233
- job_group(group).new(name, usecase: usecase, type: type, sets: sets)
234
+ def new_job(group, name, type, usecase, sets = [:core, :details, :account], &block)
235
+ job_group(group).new(name, usecase: usecase, type: type, sets: sets, &block)
234
236
  end
235
237
 
236
238
  # @see Eco::API::Session::Batch::JobsGroups#launch
@@ -96,7 +96,7 @@ module Eco
96
96
  # @param entry [Ecoportal::API::V1::Person, Enumberable<Person>] the person(s) we want to update, carrying the changes to be done.
97
97
  # @param unique [Boolean] specifies if repeated entries should be avoided in the queue.
98
98
  # @yield [person] callback before launching the batch job request against the server.
99
- # @yieldparam param [Person] current person object that that should be treated by the callback before launching the batch.
99
+ # @yieldparam person [Person] current person object that that should be treated by the callback before launching the batch.
100
100
  # @return [Eco::API::Session::Batch::Job] this `Batch::Job`.
101
101
  def add(entry, unique: true, &block)
102
102
  case entry
@@ -42,13 +42,23 @@ module Eco
42
42
  @jobs.key?(name)
43
43
  end
44
44
 
45
+ # It retrieves an existing job named `name` or creates it if it doesn't exist.
46
+ # @note
47
+ # - the block should only be passed when creating the job
48
+ # @param [see @Eco::API::Session::Batch::Jobs#new]
49
+ # @return [Eco::API::Session::Batch::Job]
45
50
  def job(name, type: nil, sets: nil, usecase: nil, &block)
51
+ fatal "Can't give a job post-launch callback &block to an already existing job" if exists?(name)
46
52
  new(name, type: type, sets: sets, usecase: usecase, &block) unless exists?(name)
47
- self[name].tap do |job|
48
- block.call(job) if block
49
- end
53
+ self[name]
50
54
  end
51
55
 
56
+ # Creates a new `Batch::Job` included as part of this `Batch::Jobs`.
57
+ # @param [see Eco::API::Session::Job#new]
58
+ # @yield [job, status] callback after launching the batch job request against the server.
59
+ # @yieldparam job [Eco::API::Session::Batch::Job] the job we have launched against the server.
60
+ # @yieldparam status [Eco::API::Session::Batch::Status] the status of the batch job launch.
61
+ # @return [Eco::API::Session::Batch::Job]
52
62
  def new(name, type:, sets:, usecase: nil, &block)
53
63
  fatal "Can't create job named '#{name}' because it already exists." if exists?(name)
54
64
 
@@ -57,6 +67,11 @@ module Eco
57
67
  end
58
68
  end
59
69
 
70
+ # @param job [Eco::API::Session::Batch::Job] the `Batch::Job` to add.
71
+ # @yield [job, status] callback after launching the batch job request against the server.
72
+ # @yieldparam job [Eco::API::Session::Batch::Job] the job we have launched against the server.
73
+ # @yieldparam status [Eco::API::Session::Batch::Status] the status of the batch job launch.
74
+ # @return [Eco::API::Session::Batch::Job]
60
75
  def add(job)
61
76
  fatal "Expected Eco::API::Session::Batch::Job object. Given #{job.class}" unless job.is_a?(Eco::API::Session::Batch::Job)
62
77
  @jobs[job.name] = job
@@ -67,6 +82,10 @@ module Eco
67
82
  any? {|job| job.pending?}
68
83
  end
69
84
 
85
+ # Launches every `Batch::Job` in the group.
86
+ # @note
87
+ # - if there was post-launch callback for a `Batch::Job`, it calls it.
88
+ # @return [Hash<Eco::API::Session::Batch::Job, Eco::API::Session::Batch::Status>]
70
89
  def launch(simulate: false)
71
90
  each do |job|
72
91
  if job.pending?
@@ -58,6 +58,11 @@ module Eco
58
58
  @groups.key?(name)
59
59
  end
60
60
 
61
+ # Creates a new group of `Batch::Jobs` named `name`.
62
+ # @yield [group, group_status] callback after launching the batch job request against the server.
63
+ # @yieldparam group [Eco::API::Session::Batch::Jobs] the group of jobs we have launched against the server.
64
+ # @yieldparam group_status [Hash<Eco::API::Session::Batch::Job, Eco::API::Session::Batch::Status>] the status of the launched batch jobs.
65
+ # @return [Eco::API::Session::Batch::Jobs] the group of jobs.
61
66
  def new(name, order: :last)
62
67
  fatal "Can't create job group named '#{name}' because it already exists." if exists?(name)
63
68
 
@@ -78,6 +83,10 @@ module Eco
78
83
  any? {|group| group.pending?}
79
84
  end
80
85
 
86
+ # Launches every `Batch::Jobs` group in the current `Batch::JobGroups`
87
+ # @note
88
+ # - if there was post-launch callback for a `Batch::Jobs` groups, it calls it.
89
+ # @return [Hash<Eco::API::Session::Batch::Jobs,Hash<Eco::API::Session::Batch::Job, Eco::API::Session::Batch::Status>>]
81
90
  def launch(simulate: false)
82
91
  @order.each_with_index do |group, idx|
83
92
  if group.pending?
@@ -4,7 +4,7 @@ class Eco::API::UseCases::DefaultCases::RefreshCase < Eco::API::Common::Loaders:
4
4
 
5
5
  def main(people, session, options, usecase)
6
6
  update = session.new_job("main", "update", :update, usecase)
7
- people.each {|person| job.add(person)}
7
+ people.each {|person| update.add(person)}
8
8
  end
9
9
 
10
10
  end
@@ -1,3 +1,3 @@
1
1
  module Eco
2
- VERSION = "1.5.7"
2
+ VERSION = "1.5.8"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: eco-helpers
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.5.7
4
+ version: 1.5.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Oscar Segura