bumbleworks 0.0.61 → 0.0.62
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/bumbleworks/process.rb +9 -7
- data/lib/bumbleworks/version.rb +1 -1
- data/lib/bumbleworks/workitem.rb +5 -0
- data/lib/bumbleworks/workitem_entity_storage.rb +11 -3
- data/spec/lib/bumbleworks/error_handler_spec.rb +5 -0
- data/spec/lib/bumbleworks/error_logger_spec.rb +6 -0
- data/spec/lib/bumbleworks/participant/local_participant_spec.rb +13 -2
- data/spec/lib/bumbleworks/process_spec.rb +34 -34
- data/spec/lib/bumbleworks/task_spec.rb +3 -9
- data/spec/lib/bumbleworks/workitem_entity_storage_spec.rb +13 -11
- data/spec/lib/bumbleworks/workitem_spec.rb +6 -0
- data/spec/support/shared_examples.rb +16 -0
- metadata +6 -4
data/lib/bumbleworks/process.rb
CHANGED
@@ -1,7 +1,11 @@
|
|
1
|
+
require "bumbleworks/workitem_entity_storage"
|
2
|
+
|
1
3
|
module Bumbleworks
|
2
4
|
class Process
|
3
5
|
class EntityConflict < StandardError; end
|
4
6
|
|
7
|
+
include WorkitemEntityStorage
|
8
|
+
|
5
9
|
attr_reader :id
|
6
10
|
|
7
11
|
class << self
|
@@ -37,18 +41,16 @@ module Bumbleworks
|
|
37
41
|
wfid == other.wfid
|
38
42
|
end
|
39
43
|
|
40
|
-
def
|
41
|
-
|
42
|
-
|
43
|
-
workitems.first.entity_fields
|
44
|
+
def entity_workitem
|
45
|
+
@entity_workitem ||= if workitems.map(&:entity_fields).uniq.length <= 1
|
46
|
+
workitems.first
|
44
47
|
else
|
45
48
|
raise EntityConflict
|
46
49
|
end
|
47
50
|
end
|
48
51
|
|
49
|
-
def
|
50
|
-
|
51
|
-
workitems.first.entity
|
52
|
+
def entity_storage_workitem
|
53
|
+
super(entity_workitem)
|
52
54
|
end
|
53
55
|
|
54
56
|
def expressions
|
data/lib/bumbleworks/version.rb
CHANGED
data/lib/bumbleworks/workitem.rb
CHANGED
@@ -2,10 +2,18 @@ module Bumbleworks
|
|
2
2
|
module WorkitemEntityStorage
|
3
3
|
extend Forwardable
|
4
4
|
|
5
|
-
delegate [:entity, :has_entity?, :has_entity_fields?, :entity_fields] => :entity_storage_workitem
|
5
|
+
delegate [:entity, :has_entity?, :has_entity_fields?, :entity_fields, :entity_name] => :entity_storage_workitem
|
6
6
|
|
7
|
-
def entity_storage_workitem
|
8
|
-
@entity_storage_workitem ||=
|
7
|
+
def entity_storage_workitem(the_workitem = workitem)
|
8
|
+
@entity_storage_workitem ||= wrapped_workitem(the_workitem)
|
9
|
+
end
|
10
|
+
|
11
|
+
def wrapped_workitem(the_workitem)
|
12
|
+
if the_workitem.is_a? Bumbleworks::Workitem
|
13
|
+
the_workitem
|
14
|
+
else
|
15
|
+
Bumbleworks::Workitem.new(the_workitem)
|
16
|
+
end
|
9
17
|
end
|
10
18
|
end
|
11
19
|
end
|
@@ -7,6 +7,11 @@ describe Bumbleworks::ErrorHandler do
|
|
7
7
|
end
|
8
8
|
end
|
9
9
|
|
10
|
+
it_behaves_like "an entity holder" do
|
11
|
+
let(:holder) { described_class.new(workitem) }
|
12
|
+
let(:storage_workitem) { Bumbleworks::Workitem.new(workitem) }
|
13
|
+
end
|
14
|
+
|
10
15
|
describe '#on_error' do
|
11
16
|
it 'raises a SubclassResponsiblity exception' do
|
12
17
|
expect{subject.on_error}.to raise_error Bumbleworks::ErrorHandler::SubclassResponsibility
|
@@ -1,6 +1,12 @@
|
|
1
1
|
describe Bumbleworks::ErrorLogger do
|
2
2
|
subject {described_class.new(workitem)}
|
3
3
|
let(:workitem) {double(:wf_name => 'armadillo', :error => 'something is amiss in dillo land', :wfid => 'zabme123', :fields => {})}
|
4
|
+
|
5
|
+
it_behaves_like "an entity holder" do
|
6
|
+
let(:holder) { described_class.new(workitem) }
|
7
|
+
let(:storage_workitem) { Bumbleworks::Workitem.new(workitem) }
|
8
|
+
end
|
9
|
+
|
4
10
|
it 'calls registered logger and logs error information' do
|
5
11
|
Bumbleworks.logger.should_receive(:error).with({
|
6
12
|
:actor => 'armadillo',
|
@@ -1,9 +1,20 @@
|
|
1
1
|
describe Bumbleworks::LocalParticipant do
|
2
|
+
let(:fake_local_participant) {
|
3
|
+
Class.new {
|
4
|
+
include Bumbleworks::LocalParticipant
|
5
|
+
attr_reader :workitem
|
6
|
+
def initialize(workitem)
|
7
|
+
@workitem = workitem
|
8
|
+
end
|
9
|
+
}
|
10
|
+
}
|
11
|
+
|
2
12
|
it 'includes Ruote::LocalParticipant' do
|
3
13
|
described_class.included_modules.should include(Ruote::LocalParticipant)
|
4
14
|
end
|
5
15
|
|
6
|
-
|
7
|
-
|
16
|
+
it_behaves_like "an entity holder" do
|
17
|
+
let(:holder) { fake_local_participant.new(:a_workitem) }
|
18
|
+
let(:storage_workitem) { Bumbleworks::Workitem.new(:a_workitem) }
|
8
19
|
end
|
9
20
|
end
|
@@ -67,7 +67,7 @@ describe Bumbleworks::Process do
|
|
67
67
|
end
|
68
68
|
|
69
69
|
describe '#workitems' do
|
70
|
-
it 'returns
|
70
|
+
it 'returns array of applied workitems from each leaf' do
|
71
71
|
bp = described_class.new('chumpy')
|
72
72
|
l1 = double(:applied_workitem => 'aw1')
|
73
73
|
l2 = double(:applied_workitem => 'aw2')
|
@@ -81,23 +81,36 @@ describe Bumbleworks::Process do
|
|
81
81
|
end
|
82
82
|
end
|
83
83
|
|
84
|
-
|
85
|
-
|
84
|
+
it_behaves_like "an entity holder" do
|
85
|
+
let(:entity_workitem) { Bumbleworks::Workitem.new(:fake_workitem) }
|
86
|
+
let(:holder) {
|
87
|
+
holder = described_class.new('nothing')
|
88
|
+
holder.stub(:entity_workitem => entity_workitem)
|
89
|
+
holder
|
90
|
+
}
|
91
|
+
let(:storage_workitem) { entity_workitem }
|
92
|
+
end
|
93
|
+
|
94
|
+
describe '#entity_workitem' do
|
95
|
+
it 'returns first workitem from workitems array, if no entity fields conflict' do
|
86
96
|
bp = described_class.new('nothing')
|
87
|
-
|
97
|
+
w1 = double(:entity_fields => :some_fields)
|
98
|
+
w2 = double(:entity_fields => :some_fields)
|
99
|
+
bp.stub(:workitems => [w1, w2])
|
100
|
+
bp.entity_workitem.should == w1
|
88
101
|
end
|
89
102
|
|
90
|
-
it 'returns
|
91
|
-
bp =
|
92
|
-
|
93
|
-
bp.entity_fields.should == {}
|
103
|
+
it 'returns nil if no process' do
|
104
|
+
bp = described_class.new('nothing')
|
105
|
+
bp.entity_workitem.should be_nil
|
94
106
|
end
|
95
107
|
|
96
|
-
it 'returns
|
108
|
+
it 'returns workitem with entity reference from process launch' do
|
97
109
|
rainbow_loom = RainbowLoom.new('1234')
|
98
110
|
bp = Bumbleworks.launch!('going_to_the_dance', :entity => rainbow_loom)
|
99
111
|
wait_until { bp.reload.trackers.count > 0 }
|
100
|
-
bp.
|
112
|
+
ew = bp.entity_workitem
|
113
|
+
ew.entity.should == rainbow_loom
|
101
114
|
end
|
102
115
|
|
103
116
|
it 'raises exception if multiple workitems have conflicting entity info' do
|
@@ -116,7 +129,17 @@ describe Bumbleworks::Process do
|
|
116
129
|
bp = Bumbleworks.launch!('conflict_this', :entity => RainbowLoom.new('1234'))
|
117
130
|
Bumbleworks.dashboard.wait_for(:just_wait)
|
118
131
|
expect {
|
119
|
-
bp.
|
132
|
+
bp.entity_workitem
|
133
|
+
}.to raise_error(Bumbleworks::Process::EntityConflict)
|
134
|
+
end
|
135
|
+
end
|
136
|
+
|
137
|
+
describe '#entity' do
|
138
|
+
it 'bubbles EntityConflict from entity_workitem' do
|
139
|
+
bp = described_class.new('whatever')
|
140
|
+
bp.stub(:entity_workitem).and_raise(Bumbleworks::Process::EntityConflict)
|
141
|
+
expect {
|
142
|
+
bp.entity
|
120
143
|
}.to raise_error(Bumbleworks::Process::EntityConflict)
|
121
144
|
end
|
122
145
|
end
|
@@ -219,29 +242,6 @@ describe Bumbleworks::Process do
|
|
219
242
|
end
|
220
243
|
end
|
221
244
|
|
222
|
-
describe '#entity' do
|
223
|
-
it 'returns nil if entity_fields is empty' do
|
224
|
-
bp = described_class.new('nothing')
|
225
|
-
bp.stub(:entity_fields => {})
|
226
|
-
bp.entity.should be_nil
|
227
|
-
end
|
228
|
-
|
229
|
-
it 'returns entity provided at launch' do
|
230
|
-
rainbow_loom = RainbowLoom.new('1234')
|
231
|
-
bp = Bumbleworks.launch!('going_to_the_dance', :entity => rainbow_loom)
|
232
|
-
wait_until { bp.reload.trackers.count > 0 }
|
233
|
-
bp.entity.should == rainbow_loom
|
234
|
-
end
|
235
|
-
|
236
|
-
it 'bubbles EntityConflict from entity_fields' do
|
237
|
-
bp = described_class.new('whatever')
|
238
|
-
bp.stub(:entity_fields).and_raise(Bumbleworks::Process::EntityConflict)
|
239
|
-
expect {
|
240
|
-
bp.entity
|
241
|
-
}.to raise_error(Bumbleworks::Process::EntityConflict)
|
242
|
-
end
|
243
|
-
end
|
244
|
-
|
245
245
|
describe '#process_status' do
|
246
246
|
it 'returns a process_status instance for the wfid' do
|
247
247
|
bp = described_class.new('frogheads')
|
@@ -8,15 +8,9 @@ describe Bumbleworks::Task do
|
|
8
8
|
Bumbleworks.start_worker!
|
9
9
|
end
|
10
10
|
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
end
|
15
|
-
|
16
|
-
it 'has a workitem method that returns workitem' do
|
17
|
-
task = described_class.new(workflow_item)
|
18
|
-
task.workitem.should == workflow_item
|
19
|
-
end
|
11
|
+
it_behaves_like "an entity holder" do
|
12
|
+
let(:holder) { described_class.new(workflow_item) }
|
13
|
+
let(:storage_workitem) { Bumbleworks::Workitem.new(workflow_item) }
|
20
14
|
end
|
21
15
|
|
22
16
|
describe '#not_completable_error_message' do
|
@@ -1,32 +1,34 @@
|
|
1
1
|
require "bumbleworks/workitem_entity_storage"
|
2
2
|
|
3
3
|
describe Bumbleworks::WorkitemEntityStorage do
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
4
|
+
let(:fake_entity_holder) {
|
5
|
+
Class.new {
|
6
|
+
include Bumbleworks::WorkitemEntityStorage
|
7
|
+
attr_reader :workitem
|
8
|
+
def initialize(workitem)
|
9
|
+
@workitem = workitem
|
10
|
+
end
|
11
|
+
}
|
12
|
+
}
|
11
13
|
|
12
14
|
describe '#entity_storage_workitem' do
|
13
15
|
it 'returns new Bumbleworks::Workitem instance with workitem' do
|
14
16
|
Bumbleworks::Workitem.stub(:new).with(:a_workitem).and_return(:the_workitem)
|
15
|
-
feh =
|
17
|
+
feh = fake_entity_holder.new(:a_workitem)
|
16
18
|
feh.entity_storage_workitem.should == :the_workitem
|
17
19
|
end
|
18
20
|
|
19
21
|
it 'is memoized' do
|
20
|
-
feh =
|
22
|
+
feh = fake_entity_holder.new(:a_workitem)
|
21
23
|
esw = feh.entity_storage_workitem
|
22
24
|
feh.entity_storage_workitem.should be esw
|
23
25
|
end
|
24
26
|
end
|
25
27
|
|
26
|
-
[:has_entity_fields?, :has_entity?, :entity, :entity_fields].each do |method|
|
28
|
+
[:has_entity_fields?, :has_entity?, :entity, :entity_fields, :entity_name].each do |method|
|
27
29
|
describe "##{method}" do
|
28
30
|
it 'delegates to entity storage workitem' do
|
29
|
-
feh =
|
31
|
+
feh = fake_entity_holder.new(:a_workitem)
|
30
32
|
feh.entity_storage_workitem.stub(method).with(1, 2, 3).and_return(:yay_for_bikes)
|
31
33
|
feh.send(method, 1, 2, 3).should == :yay_for_bikes
|
32
34
|
end
|
@@ -93,4 +93,10 @@ describe Bumbleworks::Workitem do
|
|
93
93
|
workitem.entity_fields(:titleize => true).should == { :type => 'Rainbow Loom', :identifier => '123' }
|
94
94
|
end
|
95
95
|
end
|
96
|
+
|
97
|
+
describe "#entity_name" do
|
98
|
+
it 'returns entity fields in displayable string' do
|
99
|
+
workitem.entity_name.should == 'Rainbow Loom 123'
|
100
|
+
end
|
101
|
+
end
|
96
102
|
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
shared_examples "an entity holder" do
|
2
|
+
[:has_entity_fields?, :has_entity?, :entity, :entity_fields, :entity_name].each do |method|
|
3
|
+
describe "##{method}" do
|
4
|
+
it 'delegates to entity storage workitem' do
|
5
|
+
holder.entity_storage_workitem.stub(method).with(1, 2, 3).and_return(:yay_for_bikes)
|
6
|
+
holder.send(method, 1, 2, 3).should == :yay_for_bikes
|
7
|
+
end
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
describe "#entity_storage_workitem" do
|
12
|
+
it 'returns the expected workitem' do
|
13
|
+
holder.entity_storage_workitem.should == storage_workitem
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
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.62
|
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-02-
|
15
|
+
date: 2014-02-10 00:00:00.000000000 Z
|
16
16
|
dependencies:
|
17
17
|
- !ruby/object:Gem::Dependency
|
18
18
|
name: ruote
|
@@ -246,6 +246,7 @@ files:
|
|
246
246
|
- spec/spec_helper.rb
|
247
247
|
- spec/support/path_helpers.rb
|
248
248
|
- spec/support/process_testing_helpers.rb
|
249
|
+
- spec/support/shared_examples.rb
|
249
250
|
- spec/support/tracer.rb
|
250
251
|
homepage: ''
|
251
252
|
licenses:
|
@@ -262,7 +263,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
262
263
|
version: '0'
|
263
264
|
segments:
|
264
265
|
- 0
|
265
|
-
hash:
|
266
|
+
hash: -1400629937644699968
|
266
267
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
267
268
|
none: false
|
268
269
|
requirements:
|
@@ -271,7 +272,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
271
272
|
version: '0'
|
272
273
|
segments:
|
273
274
|
- 0
|
274
|
-
hash:
|
275
|
+
hash: -1400629937644699968
|
275
276
|
requirements: []
|
276
277
|
rubyforge_project:
|
277
278
|
rubygems_version: 1.8.23
|
@@ -329,4 +330,5 @@ test_files:
|
|
329
330
|
- spec/spec_helper.rb
|
330
331
|
- spec/support/path_helpers.rb
|
331
332
|
- spec/support/process_testing_helpers.rb
|
333
|
+
- spec/support/shared_examples.rb
|
332
334
|
- spec/support/tracer.rb
|