taskinator 0.4.0 → 0.4.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a5f30cdfcc1ec3f517d2346f5eb27549cf27ed18ab830692e3747fdb1a5244e8
4
- data.tar.gz: '08299d0e337897c9efcb2080debec16072459d6a2a9fdfb8218c2bc296652a25'
3
+ metadata.gz: 4a5f5f63478b9c1b1419e33baf6039f8e92153638ba2c08dc60cadd1a968d117
4
+ data.tar.gz: e222c79a85490ec2cbced43833b05b40e97dc6863782586505b19b178e44f664
5
5
  SHA512:
6
- metadata.gz: 6d3c829ff6913bfc9c7bd41736a75b43119ebb50337eb666970e6133cbc3ee466291011c72b6213e7182111c9899706c1a241f2b3e4579474a6c1c7513e6c4d6
7
- data.tar.gz: 82c7058f70249413193d1699b8ad49e300d858d6a2d90f12c63667131399c9e33358342f6d28f36a8fd3f98d4e31c6b5a98dd4735105484e917d8262825243a2
6
+ metadata.gz: ffd5ee0e0b9bfc78e9f44086d2b60986483c4668acf9b9a282ed3110d15d59477fec68b1042876d52899fe2531648ccd793efa9ba92415231ad4e637922b8049
7
+ data.tar.gz: 99fb91f000e510dd98eda1d843e644c563ca71288759e7d23493a605b7f7b342a116cff2d2bd530250fb552cd88d728a67171fafb49419461baa7200355d9e47
data/CHANGELOG.md CHANGED
@@ -1,3 +1,8 @@
1
+ v0.4.1 - 15 Mar 2021
2
+ ---
3
+ Optimisation to exclude sub-processes which don't have any tasks.
4
+ Preparations for upgrade to Ruby 3 and ActiveSupport 6
5
+
1
6
  v0.4.0 - 4 Mar 2021
2
7
  ---
3
8
  Bug fix `job` tasks which have no arguments to the `perform` method.
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- taskinator (0.4.0)
4
+ taskinator (0.4.1)
5
5
  builder (>= 3.2.2)
6
6
  connection_pool (>= 2.2.0)
7
7
  globalid (~> 0.3)
@@ -139,4 +139,4 @@ DEPENDENCIES
139
139
  taskinator!
140
140
 
141
141
  BUNDLED WITH
142
- 2.2.13
142
+ 2.2.14
@@ -24,7 +24,10 @@ module Taskinator
24
24
  raise ArgumentError, 'block' unless block_given?
25
25
 
26
26
  sub_process = Process.define_sequential_process_for(@definition, options)
27
- Builder.new(define_sub_process_task(@process, sub_process, options), @definition, *@args).instance_eval(&block)
27
+ task = define_sub_process_task(@process, sub_process, options)
28
+ Builder.new(sub_process, @definition, *@args).instance_eval(&block)
29
+ @process.tasks << task if sub_process.tasks.any?
30
+ nil
28
31
  end
29
32
 
30
33
  # defines a sub process of tasks which are executed concurrently
@@ -32,7 +35,10 @@ module Taskinator
32
35
  raise ArgumentError, 'block' unless block_given?
33
36
 
34
37
  sub_process = Process.define_concurrent_process_for(@definition, complete_on, options)
35
- Builder.new(define_sub_process_task(@process, sub_process, options), @definition, *@args).instance_eval(&block)
38
+ task = define_sub_process_task(@process, sub_process, options)
39
+ Builder.new(sub_process, @definition, *@args).instance_eval(&block)
40
+ @process.tasks << task if sub_process.tasks.any?
41
+ nil
36
42
  end
37
43
 
38
44
  # dynamically defines tasks, using the given @iterator method
@@ -51,6 +57,7 @@ module Taskinator
51
57
  @executor.send(method, *method_args) do |*args|
52
58
  Builder.new(@process, @definition, *args).instance_eval(&block)
53
59
  end
60
+ nil
54
61
  end
55
62
 
56
63
  alias_method :transform, :for_each
@@ -61,6 +68,7 @@ module Taskinator
61
68
  raise NoMethodError, method unless @executor.respond_to?(method)
62
69
 
63
70
  define_step_task(@process, method, @args, options)
71
+ nil
64
72
  end
65
73
 
66
74
  # defines a task which executes the given @job
@@ -70,6 +78,7 @@ module Taskinator
70
78
  raise ArgumentError, 'job' unless job.methods.include?(:perform) || job.instance_methods.include?(:perform)
71
79
 
72
80
  define_job_task(@process, job, @args, options)
81
+ nil
73
82
  end
74
83
 
75
84
  # defines a sub process task, for the given @definition
@@ -82,7 +91,10 @@ module Taskinator
82
91
  # TODO: decide whether the sub process to dynamically receive arguments
83
92
 
84
93
  sub_process = definition.create_sub_process(*@args, combine_options(options))
85
- Builder.new(define_sub_process_task(@process, sub_process, options), definition, *@args)
94
+ task = define_sub_process_task(@process, sub_process, options)
95
+ Builder.new(sub_process, definition, *@args)
96
+ @process.tasks << task if sub_process.tasks.any?
97
+ nil
86
98
  end
87
99
 
88
100
  private
@@ -100,10 +112,7 @@ module Taskinator
100
112
  end
101
113
 
102
114
  def define_sub_process_task(process, sub_process, options={})
103
- define_task(process) {
104
- Task.define_sub_process_task(process, sub_process, combine_options(options))
105
- }
106
- sub_process
115
+ Task.define_sub_process_task(process, sub_process, combine_options(options))
107
116
  end
108
117
 
109
118
  def define_task(process)
@@ -1,3 +1,3 @@
1
1
  module Taskinator
2
- VERSION = "0.4.0"
2
+ VERSION = "0.4.1"
3
3
  end
@@ -75,6 +75,22 @@ describe Taskinator::Definition::Builder do
75
75
  expect(Taskinator::Process).to receive(:define_sequential_process_for).with(definition, options).and_call_original
76
76
  subject.sequential(options, &define_block)
77
77
  end
78
+
79
+ it "adds sub-process task" do
80
+ block = Proc.new {|p|
81
+ p.task :task_method
82
+ }
83
+ expect(process.tasks).to be_empty
84
+ subject.sequential(options, &block)
85
+ expect(process.tasks).to_not be_empty
86
+ end
87
+
88
+ it "ignores sub-processes without tasks" do
89
+ allow(block).to receive(:call)
90
+ expect(process.tasks).to be_empty
91
+ subject.sequential(options, &define_block)
92
+ expect(process.tasks).to be_empty
93
+ end
78
94
  end
79
95
 
80
96
  describe "#concurrent" do
@@ -100,6 +116,22 @@ describe Taskinator::Definition::Builder do
100
116
  expect(Taskinator::Process).to receive(:define_concurrent_process_for).with(definition, Taskinator::CompleteOn::First, options).and_call_original
101
117
  subject.concurrent(Taskinator::CompleteOn::First, options, &define_block)
102
118
  end
119
+
120
+ it "adds sub-process task" do
121
+ block = Proc.new {|p|
122
+ p.task :task_method
123
+ }
124
+ expect(process.tasks).to be_empty
125
+ subject.sequential(options, &block)
126
+ expect(process.tasks).to_not be_empty
127
+ end
128
+
129
+ it "ignores sub-processes without tasks" do
130
+ allow(block).to receive(:call)
131
+ expect(process.tasks).to be_empty
132
+ subject.sequential(options, &define_block)
133
+ expect(process.tasks).to be_empty
134
+ end
103
135
  end
104
136
 
105
137
  describe "#for_each" do
@@ -235,6 +267,22 @@ describe Taskinator::Definition::Builder do
235
267
  expect(sub_definition).to receive(:create_sub_process).with(*args, builder_options.merge(options)).and_call_original
236
268
  subject.sub_process(sub_definition, options)
237
269
  end
270
+
271
+ it "adds sub-process task" do
272
+ block = Proc.new {|p|
273
+ p.task :task_method
274
+ }
275
+ expect(process.tasks).to be_empty
276
+ subject.sequential(options, &block)
277
+ expect(process.tasks).to_not be_empty
278
+ end
279
+
280
+ it "ignores sub-processes without tasks" do
281
+ allow(block).to receive(:call)
282
+ expect(process.tasks).to be_empty
283
+ subject.sequential(options, &define_block)
284
+ expect(process.tasks).to be_empty
285
+ end
238
286
  end
239
287
 
240
288
  end
@@ -227,7 +227,7 @@ describe Taskinator::Task do
227
227
 
228
228
  method = subject.method
229
229
 
230
- executor.class_eval do
230
+ executor.singleton_class.class_eval do
231
231
  define_method method do |*args|
232
232
  # this method executes in the scope of the executor
233
233
  # store the context in an instance variable
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: taskinator
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.4.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chris Stefano
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-03-05 00:00:00.000000000 Z
11
+ date: 2021-03-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: redis