seam 0.0.17 → 0.0.18
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/seam/flow.rb +10 -1
- data/lib/seam/step.rb +2 -0
- data/lib/seam/version.rb +1 -1
- data/lib/seam/worker.rb +1 -0
- data/spec/seam/flow_spec.rb +10 -1
- data/spec/seam/step_spec.rb +6 -2
- data/spec/seam/worker_spec.rb +37 -5
- metadata +5 -5
data/lib/seam/flow.rb
CHANGED
@@ -20,11 +20,20 @@ module Seam
|
|
20
20
|
created_at: Time.parse(Time.now.to_s),
|
21
21
|
next_execute_at: Time.parse(Time.now.to_s),
|
22
22
|
next_step: self.steps.first.name.to_s,
|
23
|
-
flow:
|
23
|
+
flow: the_flow_from,
|
24
24
|
data: ActiveSupport::HashWithIndifferentAccess.new(data)
|
25
25
|
} )
|
26
26
|
end
|
27
27
|
|
28
|
+
def the_flow_from
|
29
|
+
hash = self.to_hash
|
30
|
+
flow = ActiveSupport::HashWithIndifferentAccess.new hash
|
31
|
+
flow['steps'].each do |step|
|
32
|
+
step['id'] = SecureRandom.uuid.to_s
|
33
|
+
end
|
34
|
+
flow
|
35
|
+
end
|
36
|
+
|
28
37
|
def to_hash
|
29
38
|
{
|
30
39
|
steps: self.steps.map { |x| x.to_hash },
|
data/lib/seam/step.rb
CHANGED
data/lib/seam/version.rb
CHANGED
data/lib/seam/worker.rb
CHANGED
data/spec/seam/flow_spec.rb
CHANGED
@@ -63,7 +63,9 @@ describe "flow" do
|
|
63
63
|
Timecop.freeze now
|
64
64
|
|
65
65
|
@expected_uuid = SecureRandom.uuid.to_s
|
66
|
-
SecureRandom.
|
66
|
+
SecureRandom.stubs(:uuid).returns(@expected_uuid)
|
67
|
+
.then.returns(1)
|
68
|
+
.then.returns(2)
|
67
69
|
|
68
70
|
@effort = flow.start( { first_name: 'John' } )
|
69
71
|
end
|
@@ -92,6 +94,13 @@ describe "flow" do
|
|
92
94
|
effort = Seam::Effort.find @effort.id
|
93
95
|
effort.to_hash.contrast_with! @effort.to_hash, [:id, :created_at]
|
94
96
|
end
|
97
|
+
|
98
|
+
it "should set unique identifiers on the flow ids" do
|
99
|
+
effort = Seam::Effort.find @effort.id
|
100
|
+
effort.flow['steps'][0]['id'].must_equal '1'
|
101
|
+
effort.flow['steps'][1]['id'].must_equal '2'
|
102
|
+
end
|
103
|
+
|
95
104
|
end
|
96
105
|
end
|
97
106
|
|
data/spec/seam/step_spec.rb
CHANGED
@@ -3,9 +3,11 @@ require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
|
|
3
3
|
describe Seam::Step do
|
4
4
|
describe "initialize" do
|
5
5
|
it "should allow values to be set with the constructor" do
|
6
|
-
step = Seam::Step.new( {
|
6
|
+
step = Seam::Step.new( { id: 'an id',
|
7
|
+
name: 'a name',
|
7
8
|
type: 'a type',
|
8
9
|
arguments: ['1234', 2] } )
|
10
|
+
step.id.must_equal 'an id'
|
9
11
|
step.name.must_equal 'a name'
|
10
12
|
step.type.must_equal 'a type'
|
11
13
|
step.arguments.count.must_equal 2
|
@@ -16,10 +18,12 @@ describe Seam::Step do
|
|
16
18
|
|
17
19
|
describe "to hash" do
|
18
20
|
it "should allow values to be set with the constructor" do
|
19
|
-
step = Seam::Step.new( {
|
21
|
+
step = Seam::Step.new( { id: 'an id',
|
22
|
+
name: 'a name',
|
20
23
|
type: 'a type',
|
21
24
|
arguments: ['1234', 2] } )
|
22
25
|
step = Seam::Step.new step.to_hash
|
26
|
+
step.id.must_equal 'an id'
|
23
27
|
step.name.must_equal 'a name'
|
24
28
|
step.type.must_equal 'a type'
|
25
29
|
step.arguments.count.must_equal 2
|
data/spec/seam/worker_spec.rb
CHANGED
@@ -605,6 +605,7 @@ describe "worker" do
|
|
605
605
|
|
606
606
|
effort.history.count.must_equal 1
|
607
607
|
effort.history[0].contrast_with!( {
|
608
|
+
"step_id" => effort.flow['steps'][0]['id'],
|
608
609
|
"started_at"=> Time.now,
|
609
610
|
"step"=>"wait_for_attempting_contact_stage",
|
610
611
|
"stopped_at" => Time.now,
|
@@ -621,7 +622,14 @@ describe "worker" do
|
|
621
622
|
effort.next_step.must_equal "wait_for_attempting_contact_stage"
|
622
623
|
|
623
624
|
effort.history.count.must_equal 1
|
624
|
-
effort.history[0].contrast_with!({
|
625
|
+
effort.history[0].contrast_with!( {
|
626
|
+
"step_id" => effort.flow['steps'][0]['id'],
|
627
|
+
"started_at"=> Time.now,
|
628
|
+
"step"=>"wait_for_attempting_contact_stage",
|
629
|
+
"stopped_at" => Time.now,
|
630
|
+
"result" => "try_again_in",
|
631
|
+
"try_again_on" => Time.now + 1.day
|
632
|
+
} )
|
625
633
|
|
626
634
|
# THE NEXT DAY
|
627
635
|
Timecop.freeze Time.parse('27/12/2013')
|
@@ -634,7 +642,13 @@ describe "worker" do
|
|
634
642
|
effort.next_step.must_equal "wait_for_attempting_contact_stage"
|
635
643
|
|
636
644
|
effort.history.count.must_equal 2
|
637
|
-
effort.history[1].contrast_with!({
|
645
|
+
effort.history[1].contrast_with!( {
|
646
|
+
"step_id" => effort.flow['steps'][0]['id'],
|
647
|
+
"started_at"=> Time.now,
|
648
|
+
"step"=>"wait_for_attempting_contact_stage",
|
649
|
+
"stopped_at" => Time.now,
|
650
|
+
"result" => "try_again_in"
|
651
|
+
} )
|
638
652
|
|
639
653
|
# THE NEXT DAY
|
640
654
|
Timecop.freeze Time.parse('28/12/2013')
|
@@ -647,7 +661,13 @@ describe "worker" do
|
|
647
661
|
effort.next_step.must_equal "determine_if_postcard_should_be_sent"
|
648
662
|
|
649
663
|
effort.history.count.must_equal 3
|
650
|
-
effort.history[2].contrast_with!({
|
664
|
+
effort.history[2].contrast_with!( {
|
665
|
+
"step_id" => effort.flow['steps'][0]['id'],
|
666
|
+
"started_at"=> Time.now,
|
667
|
+
"step"=>"wait_for_attempting_contact_stage",
|
668
|
+
"stopped_at" => Time.now,
|
669
|
+
"result" => "move_to_next_step"
|
670
|
+
} )
|
651
671
|
|
652
672
|
# KEEP GOING
|
653
673
|
send_postcard_if_necessary_worker.execute_all
|
@@ -657,7 +677,13 @@ describe "worker" do
|
|
657
677
|
effort.next_step.must_equal "send_postcard_if_necessary"
|
658
678
|
|
659
679
|
effort.history.count.must_equal 4
|
660
|
-
effort.history[3].contrast_with!({
|
680
|
+
effort.history[3].contrast_with!( {
|
681
|
+
"step_id" => effort.flow['steps'][1]['id'],
|
682
|
+
"started_at"=> Time.now,
|
683
|
+
"step"=>"determine_if_postcard_should_be_sent",
|
684
|
+
"stopped_at" => Time.now,
|
685
|
+
"result" => "move_to_next_step"
|
686
|
+
} )
|
661
687
|
|
662
688
|
# KEEP GOING
|
663
689
|
send_postcard_if_necessary_worker.execute_all
|
@@ -667,7 +693,13 @@ describe "worker" do
|
|
667
693
|
effort.next_step.must_equal nil
|
668
694
|
|
669
695
|
effort.history.count.must_equal 5
|
670
|
-
effort.history[4].contrast_with!({
|
696
|
+
effort.history[4].contrast_with!( {
|
697
|
+
"step_id" => effort.flow['steps'][2]['id'],
|
698
|
+
"started_at"=> Time.now,
|
699
|
+
"step"=>"send_postcard_if_necessary",
|
700
|
+
"stopped_at" => Time.now,
|
701
|
+
"result" => "move_to_next_step"
|
702
|
+
} )
|
671
703
|
end
|
672
704
|
end
|
673
705
|
|
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.
|
4
|
+
version: 0.0.18
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-11-
|
12
|
+
date: 2013-11-27 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: json
|
@@ -230,7 +230,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
230
230
|
version: '0'
|
231
231
|
segments:
|
232
232
|
- 0
|
233
|
-
hash: -
|
233
|
+
hash: -2525093840974074880
|
234
234
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
235
235
|
none: false
|
236
236
|
requirements:
|
@@ -239,10 +239,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
239
239
|
version: '0'
|
240
240
|
segments:
|
241
241
|
- 0
|
242
|
-
hash: -
|
242
|
+
hash: -2525093840974074880
|
243
243
|
requirements: []
|
244
244
|
rubyforge_project:
|
245
|
-
rubygems_version: 1.8.
|
245
|
+
rubygems_version: 1.8.25
|
246
246
|
signing_key:
|
247
247
|
specification_version: 3
|
248
248
|
summary: Simple workflows
|