seam 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. data/lib/seam/version.rb +1 -1
  2. data/lib/seam/worker.rb +27 -19
  3. metadata +4 -4
data/lib/seam/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Seam
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
data/lib/seam/worker.rb CHANGED
@@ -4,6 +4,14 @@ module Seam
4
4
  @step = step
5
5
  end
6
6
 
7
+ def effort
8
+ @current_effort
9
+ end
10
+
11
+ def history
12
+ @current_run
13
+ end
14
+
7
15
  def execute effort
8
16
  @current_run = HashWithIndifferentAccess.new( {
9
17
  started_at: Time.now,
@@ -12,10 +20,10 @@ module Seam
12
20
  } )
13
21
  @current_effort = effort
14
22
  process
15
- @current_run[:data_after] = effort.data
16
- @current_run[:stopped_at] = Time.now
17
- @current_effort.history << @current_run
18
- @current_effort.save
23
+ history[:data_after] = effort.data
24
+ history[:stopped_at] = Time.now
25
+ effort.history << history
26
+ effort.save
19
27
  end
20
28
 
21
29
  def execute_all
@@ -25,32 +33,32 @@ module Seam
25
33
  end
26
34
 
27
35
  def eject
28
- @current_run[:result] = "eject"
29
- @current_effort.complete = true
30
- @current_effort.next_step = nil
31
- @current_effort.save
36
+ history[:result] = "eject"
37
+ effort.complete = true
38
+ effort.next_step = nil
39
+ effort.save
32
40
  end
33
41
 
34
42
  def move_to_next_step
35
- @current_run[:result] = "move_to_next_step"
36
- @current_effort.completed_steps << @current_effort.next_step
43
+ history[:result] = "move_to_next_step"
44
+ effort.completed_steps << effort.next_step
37
45
 
38
- steps = @current_effort.flow['steps'].map { |x| x['name'] }
46
+ steps = effort.flow['steps'].map { |x| x['name'] }
39
47
 
40
- next_step = steps[@current_effort.completed_steps.count]
41
- @current_effort.next_step = next_step
42
- @current_effort.complete = next_step.nil?
43
- @current_effort.save
48
+ next_step = steps[effort.completed_steps.count]
49
+ effort.next_step = next_step
50
+ effort.complete = next_step.nil?
51
+ effort.save
44
52
  end
45
53
 
46
54
  def try_again_in seconds
47
55
  try_again_on = Time.now + seconds
48
56
 
49
- @current_run[:result] = "try_again_in"
50
- @current_run[:try_again_on] = try_again_on
57
+ history[:result] = "try_again_in"
58
+ history[:try_again_on] = try_again_on
51
59
 
52
- @current_effort.next_execute_at = try_again_on
53
- @current_effort.save
60
+ effort.next_execute_at = try_again_on
61
+ effort.save
54
62
  end
55
63
  end
56
64
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: seam
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -243,7 +243,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
243
243
  version: '0'
244
244
  segments:
245
245
  - 0
246
- hash: 1454651581186774459
246
+ hash: 4310654734258751249
247
247
  required_rubygems_version: !ruby/object:Gem::Requirement
248
248
  none: false
249
249
  requirements:
@@ -252,10 +252,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
252
252
  version: '0'
253
253
  segments:
254
254
  - 0
255
- hash: 1454651581186774459
255
+ hash: 4310654734258751249
256
256
  requirements: []
257
257
  rubyforge_project:
258
- rubygems_version: 1.8.24
258
+ rubygems_version: 1.8.25
259
259
  signing_key:
260
260
  specification_version: 3
261
261
  summary: Simple workflows