bumbleworks 0.0.60 → 0.0.61
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.
data/lib/bumbleworks/process.rb
CHANGED
|
@@ -6,38 +6,79 @@ module Bumbleworks
|
|
|
6
6
|
|
|
7
7
|
class << self
|
|
8
8
|
def all
|
|
9
|
-
|
|
9
|
+
ids.map do |wfid|
|
|
10
10
|
new(wfid)
|
|
11
11
|
end
|
|
12
12
|
end
|
|
13
|
+
|
|
14
|
+
def ids
|
|
15
|
+
Bumbleworks.dashboard.process_wfids
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def count
|
|
19
|
+
ids.count
|
|
20
|
+
end
|
|
13
21
|
end
|
|
14
22
|
|
|
15
23
|
def initialize(wfid)
|
|
16
24
|
@id = wfid
|
|
17
25
|
end
|
|
18
26
|
|
|
27
|
+
def reload
|
|
28
|
+
(instance_variables - [:@id]).each do |memo|
|
|
29
|
+
instance_variable_set(memo, nil)
|
|
30
|
+
end
|
|
31
|
+
self
|
|
32
|
+
end
|
|
33
|
+
|
|
19
34
|
alias_method :wfid, :id
|
|
20
35
|
|
|
21
36
|
def ==(other)
|
|
22
37
|
wfid == other.wfid
|
|
23
38
|
end
|
|
24
39
|
|
|
25
|
-
def
|
|
26
|
-
return
|
|
27
|
-
workitems = leaves.map(&:applied_workitem).map { |wi| Bumbleworks::Workitem.new(wi) }
|
|
40
|
+
def entity_fields
|
|
41
|
+
return {} if workitems.empty?
|
|
28
42
|
if workitems.map(&:entity_fields).uniq.length == 1
|
|
29
|
-
workitems.first.
|
|
43
|
+
workitems.first.entity_fields
|
|
30
44
|
else
|
|
31
45
|
raise EntityConflict
|
|
32
46
|
end
|
|
33
47
|
end
|
|
34
48
|
|
|
49
|
+
def entity
|
|
50
|
+
return nil if entity_fields.empty?
|
|
51
|
+
workitems.first.entity
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
def expressions
|
|
55
|
+
@expressions ||= begin
|
|
56
|
+
context = Bumbleworks.dashboard.context
|
|
57
|
+
raw_expressions = context.storage.get_many('expressions', [wfid])
|
|
58
|
+
raw_expressions.collect { |e|
|
|
59
|
+
::Ruote::Exp::FlowExpression.from_h(context, e)
|
|
60
|
+
}.sort_by { |e|
|
|
61
|
+
e.fei.expid
|
|
62
|
+
}
|
|
63
|
+
end
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
def leaves
|
|
67
|
+
@leaves ||= expressions.inject([]) { |a, exp|
|
|
68
|
+
a.select { |e| ! exp.ancestor?(e.fei) } + [ exp ]
|
|
69
|
+
}
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
def workitems
|
|
73
|
+
@workitems ||= leaves.map(&:applied_workitem).map { |wi| Bumbleworks::Workitem.new(wi) }
|
|
74
|
+
end
|
|
75
|
+
|
|
35
76
|
def tasks
|
|
36
|
-
Bumbleworks::Task.for_process(wfid)
|
|
77
|
+
@tasks ||= Bumbleworks::Task.for_process(wfid)
|
|
37
78
|
end
|
|
38
79
|
|
|
39
80
|
def trackers
|
|
40
|
-
Bumbleworks.dashboard.get_trackers.select { |tid, attrs|
|
|
81
|
+
@trackers ||= Bumbleworks.dashboard.get_trackers.select { |tid, attrs|
|
|
41
82
|
attrs['msg']['fei'] && attrs['msg']['fei']['wfid'] == id
|
|
42
83
|
}.map { |tid, original_hash|
|
|
43
84
|
Bumbleworks::Tracker.new(tid, original_hash)
|
|
@@ -45,7 +86,7 @@ module Bumbleworks
|
|
|
45
86
|
end
|
|
46
87
|
|
|
47
88
|
def all_subscribed_tags
|
|
48
|
-
trackers.inject({ :global => [] }) do |memo, t|
|
|
89
|
+
@all_subscribed_tags ||= trackers.inject({ :global => [] }) do |memo, t|
|
|
49
90
|
if t.global?
|
|
50
91
|
memo[:global].concat t.tags
|
|
51
92
|
else
|
|
@@ -72,7 +113,7 @@ module Bumbleworks
|
|
|
72
113
|
end
|
|
73
114
|
|
|
74
115
|
def process_status
|
|
75
|
-
Bumbleworks.dashboard.process(id)
|
|
116
|
+
@process_status ||= Bumbleworks.dashboard.process(id)
|
|
76
117
|
end
|
|
77
118
|
|
|
78
119
|
def method_missing(method, *args)
|
data/lib/bumbleworks/version.rb
CHANGED
data/lib/bumbleworks/workitem.rb
CHANGED
|
@@ -1,9 +1,15 @@
|
|
|
1
1
|
module Bumbleworks
|
|
2
2
|
class Workitem
|
|
3
|
+
attr_reader :raw_workitem
|
|
4
|
+
|
|
3
5
|
def initialize(raw_workitem)
|
|
4
6
|
@raw_workitem = raw_workitem
|
|
5
7
|
end
|
|
6
8
|
|
|
9
|
+
def ==(other)
|
|
10
|
+
raw_workitem == other.raw_workitem
|
|
11
|
+
end
|
|
12
|
+
|
|
7
13
|
def entity(options = {})
|
|
8
14
|
@entity = nil if options[:reload] == true
|
|
9
15
|
@entity ||= if has_entity_fields?
|
|
@@ -25,13 +25,30 @@ describe Bumbleworks::Process do
|
|
|
25
25
|
end
|
|
26
26
|
end
|
|
27
27
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
bp1 = Bumbleworks.launch!('going_to_the_dance')
|
|
31
|
-
bp2 = Bumbleworks.launch!('going_to_the_dance')
|
|
32
|
-
bp3 = Bumbleworks.launch!('straightening_the_rocks')
|
|
28
|
+
context 'aggregate methods' do
|
|
29
|
+
before(:each) do
|
|
30
|
+
@bp1 = Bumbleworks.launch!('going_to_the_dance')
|
|
31
|
+
@bp2 = Bumbleworks.launch!('going_to_the_dance')
|
|
32
|
+
@bp3 = Bumbleworks.launch!('straightening_the_rocks')
|
|
33
33
|
wait_until { Bumbleworks.dashboard.process_wfids.count == 3 }
|
|
34
|
-
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
describe '.all' do
|
|
37
|
+
it 'returns instances for all process wfids' do
|
|
38
|
+
described_class.all.should =~ [@bp1, @bp2, @bp3]
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
describe '.ids' do
|
|
43
|
+
it 'returns all process wfids' do
|
|
44
|
+
described_class.ids.should =~ [@bp1.wfid, @bp2.wfid, @bp3.wfid]
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
describe '.count' do
|
|
49
|
+
it 'returns number of processes' do
|
|
50
|
+
described_class.count.should == 3
|
|
51
|
+
end
|
|
35
52
|
end
|
|
36
53
|
end
|
|
37
54
|
|
|
@@ -49,6 +66,61 @@ describe Bumbleworks::Process do
|
|
|
49
66
|
end
|
|
50
67
|
end
|
|
51
68
|
|
|
69
|
+
describe '#workitems' do
|
|
70
|
+
it 'returns task query filtered for this process' do
|
|
71
|
+
bp = described_class.new('chumpy')
|
|
72
|
+
l1 = double(:applied_workitem => 'aw1')
|
|
73
|
+
l2 = double(:applied_workitem => 'aw2')
|
|
74
|
+
l3 = double(:applied_workitem => 'aw3')
|
|
75
|
+
bp.stub(:leaves => [l1, l2, l3])
|
|
76
|
+
bp.workitems.should == [
|
|
77
|
+
Bumbleworks::Workitem.new('aw1'),
|
|
78
|
+
Bumbleworks::Workitem.new('aw2'),
|
|
79
|
+
Bumbleworks::Workitem.new('aw3')
|
|
80
|
+
]
|
|
81
|
+
end
|
|
82
|
+
end
|
|
83
|
+
|
|
84
|
+
describe '#entity_fields' do
|
|
85
|
+
it 'returns empty hash if process not ready yet' do
|
|
86
|
+
bp = described_class.new('nothing')
|
|
87
|
+
bp.entity_fields.should == {}
|
|
88
|
+
end
|
|
89
|
+
|
|
90
|
+
it 'returns empty hash if no entity' do
|
|
91
|
+
bp = Bumbleworks.launch!('going_to_the_dance')
|
|
92
|
+
wait_until { bp.reload.trackers.count > 0 }
|
|
93
|
+
bp.entity_fields.should == {}
|
|
94
|
+
end
|
|
95
|
+
|
|
96
|
+
it 'returns entity_fields provided at launch' do
|
|
97
|
+
rainbow_loom = RainbowLoom.new('1234')
|
|
98
|
+
bp = Bumbleworks.launch!('going_to_the_dance', :entity => rainbow_loom)
|
|
99
|
+
wait_until { bp.reload.trackers.count > 0 }
|
|
100
|
+
bp.entity_fields.should == { :type => 'RainbowLoom', :identifier => '1234'}
|
|
101
|
+
end
|
|
102
|
+
|
|
103
|
+
it 'raises exception if multiple workitems have conflicting entity info' do
|
|
104
|
+
Bumbleworks.define_process 'conflict_this' do
|
|
105
|
+
concurrence do
|
|
106
|
+
sequence do
|
|
107
|
+
set 'entity_id' => 'swoo'
|
|
108
|
+
just_wait
|
|
109
|
+
end
|
|
110
|
+
sequence do
|
|
111
|
+
set 'entity_id' => 'fwee'
|
|
112
|
+
just_wait
|
|
113
|
+
end
|
|
114
|
+
end
|
|
115
|
+
end
|
|
116
|
+
bp = Bumbleworks.launch!('conflict_this', :entity => RainbowLoom.new('1234'))
|
|
117
|
+
Bumbleworks.dashboard.wait_for(:just_wait)
|
|
118
|
+
expect {
|
|
119
|
+
bp.entity_fields
|
|
120
|
+
}.to raise_error(Bumbleworks::Process::EntityConflict)
|
|
121
|
+
end
|
|
122
|
+
end
|
|
123
|
+
|
|
52
124
|
describe '#tasks' do
|
|
53
125
|
it 'returns task query filtered for this process' do
|
|
54
126
|
bp = described_class.new('chumpy')
|
|
@@ -61,7 +133,7 @@ describe Bumbleworks::Process do
|
|
|
61
133
|
it 'lists all trackers this process is waiting on' do
|
|
62
134
|
bp1 = Bumbleworks.launch!('going_to_the_dance')
|
|
63
135
|
bp2 = Bumbleworks.launch!('straightening_the_rocks')
|
|
64
|
-
wait_until { bp1.trackers.count == 3 && bp2.trackers.count == 2 }
|
|
136
|
+
wait_until { bp1.reload.trackers.count == 3 && bp2.reload.trackers.count == 2 }
|
|
65
137
|
bp1.trackers.map { |t| t.process }.should == [bp1, bp1, bp1]
|
|
66
138
|
bp2.trackers.map { |t| t.process }.should == [bp2, bp2]
|
|
67
139
|
bp1.trackers.map { |t| t.action }.should == ['left_tag', 'left_tag', 'dispatch']
|
|
@@ -75,14 +147,14 @@ describe Bumbleworks::Process do
|
|
|
75
147
|
it 'lists all tags this process is waiting on' do
|
|
76
148
|
bp1 = Bumbleworks.launch!('going_to_the_dance')
|
|
77
149
|
bp2 = Bumbleworks.launch!('straightening_the_rocks')
|
|
78
|
-
wait_until { bp1.trackers.count == 3 && bp2.trackers.count == 2 }
|
|
150
|
+
wait_until { bp1.reload.trackers.count == 3 && bp2.reload.trackers.count == 2 }
|
|
79
151
|
bp1.all_subscribed_tags.should == { :global => ['an_invitation'], bp1.wfid => ['a_friend'] }
|
|
80
152
|
bp2.all_subscribed_tags.should == { :global => ['rock_caliper_delivery', 'speedos'] }
|
|
81
153
|
end
|
|
82
154
|
|
|
83
155
|
it 'sets global tags to empty array by default' do
|
|
84
156
|
bp = Bumbleworks.launch!('i_wait_for_nobody')
|
|
85
|
-
wait_until { bp.tasks.count == 1 }
|
|
157
|
+
wait_until { bp.reload.tasks.count == 1 }
|
|
86
158
|
bp.all_subscribed_tags.should == { :global => [] }
|
|
87
159
|
end
|
|
88
160
|
end
|
|
@@ -91,14 +163,14 @@ describe Bumbleworks::Process do
|
|
|
91
163
|
it 'lists all events (global tags) this process is waiting on' do
|
|
92
164
|
bp1 = Bumbleworks.launch!('going_to_the_dance')
|
|
93
165
|
bp2 = Bumbleworks.launch!('straightening_the_rocks')
|
|
94
|
-
wait_until { bp1.trackers.count == 3 && bp2.trackers.count == 2 }
|
|
166
|
+
wait_until { bp1.reload.trackers.count == 3 && bp2.reload.trackers.count == 2 }
|
|
95
167
|
bp1.subscribed_events.should == ['an_invitation']
|
|
96
168
|
bp2.subscribed_events.should == ['rock_caliper_delivery', 'speedos']
|
|
97
169
|
end
|
|
98
170
|
|
|
99
171
|
it 'returns empty array if no global tags' do
|
|
100
172
|
bp = Bumbleworks.launch!('i_wait_for_nobody')
|
|
101
|
-
wait_until { bp.tasks.count == 1 }
|
|
173
|
+
wait_until { bp.reload.tasks.count == 1 }
|
|
102
174
|
bp.subscribed_events.should == []
|
|
103
175
|
end
|
|
104
176
|
end
|
|
@@ -148,43 +220,26 @@ describe Bumbleworks::Process do
|
|
|
148
220
|
end
|
|
149
221
|
|
|
150
222
|
describe '#entity' do
|
|
151
|
-
it 'returns nil if
|
|
223
|
+
it 'returns nil if entity_fields is empty' do
|
|
152
224
|
bp = described_class.new('nothing')
|
|
225
|
+
bp.stub(:entity_fields => {})
|
|
153
226
|
bp.entity.should be_nil
|
|
154
227
|
end
|
|
155
228
|
|
|
156
229
|
it 'returns entity provided at launch' do
|
|
157
230
|
rainbow_loom = RainbowLoom.new('1234')
|
|
158
231
|
bp = Bumbleworks.launch!('going_to_the_dance', :entity => rainbow_loom)
|
|
159
|
-
wait_until { bp.trackers.count > 0 }
|
|
232
|
+
wait_until { bp.reload.trackers.count > 0 }
|
|
160
233
|
bp.entity.should == rainbow_loom
|
|
161
234
|
end
|
|
162
235
|
|
|
163
|
-
it '
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
sequence do
|
|
167
|
-
set 'entity_id' => 'swoo'
|
|
168
|
-
just_wait
|
|
169
|
-
end
|
|
170
|
-
sequence do
|
|
171
|
-
set 'entity_id' => 'fwee'
|
|
172
|
-
just_wait
|
|
173
|
-
end
|
|
174
|
-
end
|
|
175
|
-
end
|
|
176
|
-
bp = Bumbleworks.launch!('conflict_this', :entity => RainbowLoom.new('1234'))
|
|
177
|
-
Bumbleworks.dashboard.wait_for(:just_wait)
|
|
236
|
+
it 'bubbles EntityConflict from entity_fields' do
|
|
237
|
+
bp = described_class.new('whatever')
|
|
238
|
+
bp.stub(:entity_fields).and_raise(Bumbleworks::Process::EntityConflict)
|
|
178
239
|
expect {
|
|
179
240
|
bp.entity
|
|
180
241
|
}.to raise_error(Bumbleworks::Process::EntityConflict)
|
|
181
242
|
end
|
|
182
|
-
|
|
183
|
-
it 'returns nil if no entity' do
|
|
184
|
-
bp = Bumbleworks.launch!('going_to_the_dance')
|
|
185
|
-
wait_until { bp.trackers.count > 0 }
|
|
186
|
-
bp.entity.should be_nil
|
|
187
|
-
end
|
|
188
243
|
end
|
|
189
244
|
|
|
190
245
|
describe '#process_status' do
|
|
@@ -4,6 +4,14 @@ describe Bumbleworks::Workitem do
|
|
|
4
4
|
let(:ruote_workitem) { Ruote::Workitem.new('fields' => {'entity_id' => '123', 'entity_type' => 'RainbowLoom'} ) }
|
|
5
5
|
let(:workitem) { Bumbleworks::Workitem.new(ruote_workitem)}
|
|
6
6
|
|
|
7
|
+
describe '#==' do
|
|
8
|
+
it 'returns true if other object has same raw workitem' do
|
|
9
|
+
bw1 = described_class.new('in_da_sky')
|
|
10
|
+
bw2 = described_class.new('in_da_sky')
|
|
11
|
+
bw1.should == bw2
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
|
|
7
15
|
describe '#has_entity_fields?' do
|
|
8
16
|
it 'returns true if workitem fields include entity fields' do
|
|
9
17
|
workitem.should have_entity_fields
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: bumbleworks
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.0.
|
|
4
|
+
version: 0.0.61
|
|
5
5
|
prerelease:
|
|
6
6
|
platform: ruby
|
|
7
7
|
authors:
|
|
@@ -12,7 +12,7 @@ authors:
|
|
|
12
12
|
autorequire:
|
|
13
13
|
bindir: bin
|
|
14
14
|
cert_chain: []
|
|
15
|
-
date: 2014-
|
|
15
|
+
date: 2014-02-07 00:00:00.000000000 Z
|
|
16
16
|
dependencies:
|
|
17
17
|
- !ruby/object:Gem::Dependency
|
|
18
18
|
name: ruote
|
|
@@ -262,7 +262,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
262
262
|
version: '0'
|
|
263
263
|
segments:
|
|
264
264
|
- 0
|
|
265
|
-
hash:
|
|
265
|
+
hash: 1220168955592203945
|
|
266
266
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
267
267
|
none: false
|
|
268
268
|
requirements:
|
|
@@ -271,7 +271,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
271
271
|
version: '0'
|
|
272
272
|
segments:
|
|
273
273
|
- 0
|
|
274
|
-
hash:
|
|
274
|
+
hash: 1220168955592203945
|
|
275
275
|
requirements: []
|
|
276
276
|
rubyforge_project:
|
|
277
277
|
rubygems_version: 1.8.23
|