taskinator 0.0.13 → 0.0.14

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
  SHA1:
3
- metadata.gz: e525f7ac6b173f06d6a4e9a3bcf498bfdde1e434
4
- data.tar.gz: 13c8c943739f8cb17474cac9a7634a37dcf95a1e
3
+ metadata.gz: 51c713c1cb5cfa95439381d7f120bfa2bfb846b6
4
+ data.tar.gz: 79d1bcb30bae42edad8428fefc19e4870f0c5024
5
5
  SHA512:
6
- metadata.gz: 4f8cab5e41d5b606778a1ea67178cfb68c7143ec447d5f3a3ef793ee26e0c45d58fcb1e5152b251a76a161f7247b32d5be6432a0cfc402cb1bb37112ce7f05c8
7
- data.tar.gz: 526147b769e9b37e05e6fd59e8aafbaed5b64cbd00a5a2910f99b1fbd6bdeae5fb238ad0950bd1bb93f3efc0c8a47c7d835437db08d166803a27f8c32a518e05
6
+ metadata.gz: a2ad95201f5f020d97f731122071a57a3aa092163594a2bc72982950596589af3deb97daebd082c32ad9959695785f36018c730428d4638eb50f27cf4bf8a869
7
+ data.tar.gz: 023087cad85ee39f7cbea9310277b8e382c4926696677a89ebd9c5889a6ff48e9d60c59c085ff7851f4d368330ad6976963a0cb7d741bffb79cdde424b36ab52
data/Gemfile.lock CHANGED
@@ -8,7 +8,7 @@ GIT
8
8
  PATH
9
9
  remote: .
10
10
  specs:
11
- taskinator (0.0.13)
11
+ taskinator (0.0.14)
12
12
  connection_pool (>= 2.0.0)
13
13
  json (>= 1.8.1)
14
14
  redis (>= 3.0.6)
@@ -42,7 +42,13 @@ module Taskinator
42
42
  raise NoMethodError, method unless @executor.respond_to?(method)
43
43
  raise ArgumentError, 'block' unless block_given?
44
44
 
45
- @executor.send(method, *[*@args, options]) do |*args|
45
+ #
46
+ # `for_each` is an exception, since it invokes the definition
47
+ # in order to yield elements to the builder, and any options passed
48
+ # are included with the builder options
49
+ #
50
+ method_args = options.any? ? [*@args, options] : @args
51
+ @executor.send(method, *method_args) do |*args|
46
52
  Builder.new(@process, @definition, *args).instance_eval(&block)
47
53
  end
48
54
  end
@@ -7,6 +7,9 @@ module Taskinator
7
7
  define_singleton_method :_create_process_ do |args, options={}|
8
8
 
9
9
  # TODO: better validation of arguments
10
+
11
+ # FIXME: arg_list should only contain an array of symbols
12
+
10
13
  raise ArgumentError, "wrong number of arguments (#{args.length} for #{arg_list.length})" if args.length < arg_list.length
11
14
 
12
15
  process = Process.define_sequential_process_for(self)
@@ -93,7 +93,8 @@ module Taskinator
93
93
  end
94
94
 
95
95
  # persists the error information
96
- def fail(error)
96
+ def fail(error=nil)
97
+ return unless error
97
98
  Taskinator.redis do |conn|
98
99
  conn.hmset(
99
100
  self.key,
@@ -35,7 +35,7 @@ module Taskinator
35
35
  return to_enum(__method__) unless block_given?
36
36
 
37
37
  current = @head
38
- while current != nil
38
+ while current
39
39
  yield current
40
40
  current = current.next
41
41
  end
@@ -1,3 +1,3 @@
1
1
  module Taskinator
2
- VERSION = "0.0.13"
2
+ VERSION = "0.0.14"
3
3
  end
@@ -99,7 +99,7 @@ describe Taskinator::Definition::Builder do
99
99
  @executor = executor
100
100
  end
101
101
 
102
- expect(executor).to receive(:iterator_method).with(*[*args, {}]) do |*a, &block|
102
+ expect(executor).to receive(:iterator_method).with(*args) do |*a, &block|
103
103
  3.times(&block)
104
104
  end
105
105
 
@@ -41,7 +41,7 @@ describe Taskinator::Definition do
41
41
  allow(block).to receive(:to_proc) {
42
42
  Proc.new {|*args| }
43
43
  }
44
- subject.define_process &block
44
+ subject.define_process(&block)
45
45
 
46
46
  expect(subject.create_process).to be_a(Taskinator::Process)
47
47
  end
@@ -144,13 +144,13 @@ describe Taskinator::Process do
144
144
  describe "#fail!" do
145
145
  it { expect(subject).to respond_to(:fail!) }
146
146
  it {
147
- expect(subject).to receive(:fail).with(StandardError)
147
+ expect(subject).to receive(:fail)
148
148
  subject.start!
149
- subject.fail!(StandardError)
149
+ subject.fail!
150
150
  }
151
151
  it {
152
152
  subject.start!
153
- subject.fail!(StandardError)
153
+ subject.fail!
154
154
  expect(subject.current_state.name).to eq(:failed)
155
155
  }
156
156
  end
@@ -363,9 +363,11 @@ describe Taskinator::Process do
363
363
  it "fails when tasks fail" do
364
364
  tasks.each {|t| subject.tasks << t }
365
365
 
366
- expect(subject).to receive(:fail!).with(StandardError)
366
+ error = StandardError.new
367
367
 
368
- subject.task_failed(tasks.first, StandardError)
368
+ expect(subject).to receive(:fail!).with(error)
369
+
370
+ subject.task_failed(tasks.first, error)
369
371
  end
370
372
  end
371
373
 
@@ -95,14 +95,15 @@ describe Taskinator::Task do
95
95
  describe "#fail!" do
96
96
  it { expect(subject).to respond_to(:fail!) }
97
97
  it {
98
- expect(subject).to receive(:fail).with(StandardError)
99
- expect(process).to receive(:task_failed).with(subject, StandardError)
98
+ error = StandardError.new
99
+ expect(subject).to receive(:fail).with(error)
100
+ expect(process).to receive(:task_failed).with(subject, error)
100
101
  subject.start!
101
- subject.fail!(StandardError)
102
+ subject.fail!(error)
102
103
  }
103
104
  it {
104
105
  subject.start!
105
- subject.fail!(StandardError)
106
+ subject.fail!
106
107
  expect(subject.current_state.name).to eq(:failed)
107
108
  }
108
109
  end
@@ -171,8 +172,9 @@ describe Taskinator::Task do
171
172
  end
172
173
 
173
174
  it "handles failure" do
174
- allow(subject.executor).to receive(subject.method).with(*subject.args).and_raise(StandardError)
175
- expect(subject).to receive(:fail!).with(StandardError)
175
+ error = StandardError.new
176
+ allow(subject.executor).to receive(subject.method).with(*subject.args).and_raise(error)
177
+ expect(subject).to receive(:fail!).with(error)
176
178
  subject.start!
177
179
  end
178
180
  end
@@ -278,8 +280,9 @@ describe Taskinator::Task do
278
280
  end
279
281
 
280
282
  it "handles failure" do
281
- allow(sub_process).to receive(:start!).and_raise(StandardError)
282
- expect(subject).to receive(:fail!).with(StandardError)
283
+ error = StandardError.new
284
+ allow(sub_process).to receive(:start!).and_raise(error)
285
+ expect(subject).to receive(:fail!).with(error)
283
286
  subject.start!
284
287
  end
285
288
  end
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.0.13
4
+ version: 0.0.14
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chris Stefano
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-05-11 00:00:00.000000000 Z
11
+ date: 2015-05-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: redis