bumbleworks 0.0.50 → 0.0.51
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/participant.rb +5 -10
- data/lib/bumbleworks/participants/entity_interactor.rb +27 -0
- data/lib/bumbleworks/participants/error_dispatcher.rb +12 -0
- data/lib/bumbleworks/participants/local_participant.rb +9 -0
- data/lib/bumbleworks/participants/participant.rb +9 -0
- data/lib/bumbleworks/participants/storage_participant.rb +9 -0
- data/lib/bumbleworks/ruote.rb +10 -10
- data/lib/bumbleworks/version.rb +1 -1
- data/spec/integration/sample_application_spec.rb +3 -3
- data/spec/lib/bumbleworks/participant/base_spec.rb +3 -3
- data/spec/lib/bumbleworks/participant/entity_interactor_spec.rb +1 -1
- data/spec/lib/bumbleworks/participant/{error_handler_spec.rb → error_dispatcher_spec.rb} +1 -1
- data/spec/lib/bumbleworks/participant/local_participant_spec.rb +1 -1
- data/spec/lib/bumbleworks/ruote_spec.rb +22 -22
- metadata +10 -10
- data/lib/bumbleworks/participant/base.rb +0 -11
- data/lib/bumbleworks/participant/entity_interactor.rb +0 -29
- data/lib/bumbleworks/participant/error_handler.rb +0 -14
- data/lib/bumbleworks/participant/local_participant.rb +0 -11
- data/lib/bumbleworks/participant/storage_participant.rb +0 -11
@@ -1,10 +1,5 @@
|
|
1
|
-
require "bumbleworks/
|
2
|
-
require "bumbleworks/
|
3
|
-
require "bumbleworks/participant
|
4
|
-
require "bumbleworks/
|
5
|
-
require "bumbleworks/
|
6
|
-
|
7
|
-
module Bumbleworks
|
8
|
-
module Participant
|
9
|
-
end
|
10
|
-
end
|
1
|
+
require "bumbleworks/participants/storage_participant"
|
2
|
+
require "bumbleworks/participants/local_participant"
|
3
|
+
require "bumbleworks/participants/participant"
|
4
|
+
require "bumbleworks/participants/error_dispatcher"
|
5
|
+
require "bumbleworks/participants/entity_interactor"
|
@@ -0,0 +1,27 @@
|
|
1
|
+
module Bumbleworks
|
2
|
+
class EntityInteractor < Bumbleworks::Participant
|
3
|
+
def on_workitem
|
4
|
+
method_name = workitem.fields['params']['method'] ||
|
5
|
+
workitem.fields['params']['to'] ||
|
6
|
+
workitem.fields['params']['for']
|
7
|
+
result_field = workitem.fields['params']['and_save_as']
|
8
|
+
arguments = workitem.fields['params']['arguments'] ||
|
9
|
+
workitem.fields['params']['with']
|
10
|
+
result = call_method(method_name, :save_as => result_field, :args => arguments)
|
11
|
+
reply
|
12
|
+
end
|
13
|
+
|
14
|
+
def call_method(method_name, options = {})
|
15
|
+
result = if options[:args]
|
16
|
+
options[:args] = [options[:args]] if options[:args].is_a?(Hash)
|
17
|
+
entity.send(method_name, *options[:args])
|
18
|
+
else
|
19
|
+
entity.send(method_name)
|
20
|
+
end
|
21
|
+
if result && options[:save_as]
|
22
|
+
workitem.fields[options[:save_as]] = result
|
23
|
+
end
|
24
|
+
result
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
module Bumbleworks
|
2
|
+
class ErrorDispatcher < Bumbleworks::Participant
|
3
|
+
def on_workitem
|
4
|
+
return if (error_handlers = Bumbleworks.error_handlers).empty?
|
5
|
+
|
6
|
+
error_handlers.each do |error_handler|
|
7
|
+
error_handler.new(workitem).on_error
|
8
|
+
end
|
9
|
+
reply
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
data/lib/bumbleworks/ruote.rb
CHANGED
@@ -29,7 +29,7 @@ module Bumbleworks
|
|
29
29
|
#
|
30
30
|
def start_worker!(options = {})
|
31
31
|
set_up_storage_history
|
32
|
-
|
32
|
+
register_error_dispatcher
|
33
33
|
dashboard.noisy = options[:verbose] == true
|
34
34
|
worker = ::Ruote::Worker.new(dashboard.context)
|
35
35
|
if options[:join] == true
|
@@ -101,23 +101,23 @@ module Bumbleworks
|
|
101
101
|
def register_participants(&block)
|
102
102
|
dashboard.register(&block) if block
|
103
103
|
register_entity_interactor
|
104
|
-
|
104
|
+
register_error_dispatcher
|
105
105
|
set_catchall_if_needed
|
106
106
|
dashboard.participant_list
|
107
107
|
end
|
108
108
|
|
109
109
|
def register_entity_interactor
|
110
110
|
unless dashboard.participant_list.any? { |part| part.regex == "^(ask|tell)_entity$" }
|
111
|
-
entity_interactor = ::Ruote::ParticipantEntry.new(["^(ask|tell)_entity$", ["Bumbleworks::
|
111
|
+
entity_interactor = ::Ruote::ParticipantEntry.new(["^(ask|tell)_entity$", ["Bumbleworks::EntityInteractor", {}]])
|
112
112
|
dashboard.participant_list = dashboard.participant_list.unshift(entity_interactor)
|
113
113
|
end
|
114
114
|
end
|
115
115
|
|
116
|
-
def
|
117
|
-
unless dashboard.participant_list.any? { |part| part.regex == '^
|
118
|
-
|
119
|
-
dashboard.participant_list = dashboard.participant_list.unshift(
|
120
|
-
dashboard.on_error = '
|
116
|
+
def register_error_dispatcher
|
117
|
+
unless dashboard.participant_list.any? { |part| part.regex == '^error_dispatcher$' }
|
118
|
+
error_dispatcher = ::Ruote::ParticipantEntry.new(['^error_dispatcher$', ["Bumbleworks::ErrorDispatcher", {}]])
|
119
|
+
dashboard.participant_list = dashboard.participant_list.unshift(error_dispatcher)
|
120
|
+
dashboard.on_error = 'error_dispatcher'
|
121
121
|
end
|
122
122
|
end
|
123
123
|
|
@@ -130,8 +130,8 @@ module Bumbleworks
|
|
130
130
|
def set_catchall_if_needed
|
131
131
|
last_participant = dashboard.participant_list.last
|
132
132
|
unless last_participant && last_participant.regex == "^.+$" &&
|
133
|
-
["Ruote::StorageParticipant", "Bumbleworks::
|
134
|
-
catchall = ::Ruote::ParticipantEntry.new(["^.+$", ["Bumbleworks::
|
133
|
+
["Ruote::StorageParticipant", "Bumbleworks::StorageParticipant"].include?(last_participant.classname)
|
134
|
+
catchall = ::Ruote::ParticipantEntry.new(["^.+$", ["Bumbleworks::StorageParticipant", {}]])
|
135
135
|
dashboard.participant_list = dashboard.participant_list.push(catchall)
|
136
136
|
end
|
137
137
|
end
|
data/lib/bumbleworks/version.rb
CHANGED
@@ -12,11 +12,11 @@ describe 'Bumbleworks Sample Application' do
|
|
12
12
|
it 'registers participants' do
|
13
13
|
Bumbleworks.dashboard.participant_list.should have(5).items
|
14
14
|
Bumbleworks.dashboard.participant_list.map(&:classname).should == [
|
15
|
-
'Bumbleworks::
|
16
|
-
'Bumbleworks::
|
15
|
+
'Bumbleworks::ErrorDispatcher',
|
16
|
+
'Bumbleworks::EntityInteractor',
|
17
17
|
'HoneyParticipant',
|
18
18
|
'MolassesParticipant',
|
19
|
-
'Bumbleworks::
|
19
|
+
'Bumbleworks::StorageParticipant'
|
20
20
|
]
|
21
21
|
end
|
22
22
|
|
@@ -1,6 +1,6 @@
|
|
1
|
-
describe Bumbleworks::Participant
|
2
|
-
it 'includes Bumbleworks::
|
3
|
-
described_class.included_modules.should include(Bumbleworks::
|
1
|
+
describe Bumbleworks::Participant do
|
2
|
+
it 'includes Bumbleworks::LocalParticipant' do
|
3
|
+
described_class.included_modules.should include(Bumbleworks::LocalParticipant)
|
4
4
|
end
|
5
5
|
|
6
6
|
it 'defines #on_cancel' do
|
@@ -1,4 +1,4 @@
|
|
1
|
-
describe Bumbleworks::
|
1
|
+
describe Bumbleworks::EntityInteractor do
|
2
2
|
let(:entity) { double('entity', :cheek_depth => 'crazy deep') }
|
3
3
|
let(:workitem) { Ruote::Workitem.new('fields' => { 'params' => { 'method' => 'cheek_depth' }}) }
|
4
4
|
subject { part = described_class.new; part.stub(:entity => entity, :reply => nil); part }
|
@@ -222,7 +222,7 @@ describe Bumbleworks::Ruote do
|
|
222
222
|
end
|
223
223
|
|
224
224
|
it 'registers error handler' do
|
225
|
-
described_class.should_receive(:
|
225
|
+
described_class.should_receive(:register_error_dispatcher)
|
226
226
|
described_class.start_worker!
|
227
227
|
end
|
228
228
|
|
@@ -231,15 +231,15 @@ describe Bumbleworks::Ruote do
|
|
231
231
|
described_class.start_worker!
|
232
232
|
end
|
233
233
|
|
234
|
-
it 'does not add another
|
234
|
+
it 'does not add another error_dispatcher if already registered' do
|
235
235
|
described_class.register_participants
|
236
236
|
described_class.start_worker!
|
237
237
|
described_class.dashboard.participant_list.map(&:classname).should == [
|
238
|
-
'Bumbleworks::
|
239
|
-
'Bumbleworks::
|
240
|
-
'Bumbleworks::
|
238
|
+
'Bumbleworks::ErrorDispatcher',
|
239
|
+
'Bumbleworks::EntityInteractor',
|
240
|
+
'Bumbleworks::StorageParticipant'
|
241
241
|
]
|
242
|
-
Bumbleworks.dashboard.on_error.flatten[2].should == '
|
242
|
+
Bumbleworks.dashboard.on_error.flatten[2].should == 'error_dispatcher'
|
243
243
|
end
|
244
244
|
end
|
245
245
|
|
@@ -284,10 +284,10 @@ describe Bumbleworks::Ruote do
|
|
284
284
|
described_class.register_participants ®istration_block
|
285
285
|
described_class.dashboard.participant_list.should have(6).items
|
286
286
|
described_class.dashboard.participant_list.map(&:classname).should == [
|
287
|
-
'Bumbleworks::
|
288
|
-
'Bumbleworks::
|
287
|
+
'Bumbleworks::ErrorDispatcher',
|
288
|
+
'Bumbleworks::EntityInteractor',
|
289
289
|
'BeesHoney', 'MapleSyrup', 'NewCatchall',
|
290
|
-
'Bumbleworks::
|
290
|
+
'Bumbleworks::StorageParticipant'
|
291
291
|
]
|
292
292
|
end
|
293
293
|
|
@@ -301,7 +301,7 @@ describe Bumbleworks::Ruote do
|
|
301
301
|
described_class.register_participants ®istration_block
|
302
302
|
described_class.dashboard.participant_list.should have(4).items
|
303
303
|
described_class.dashboard.participant_list.map(&:classname).should == [
|
304
|
-
'Bumbleworks::
|
304
|
+
'Bumbleworks::ErrorDispatcher', 'Bumbleworks::EntityInteractor', 'BeesHoney', 'Ruote::StorageParticipant'
|
305
305
|
]
|
306
306
|
end
|
307
307
|
|
@@ -310,28 +310,28 @@ describe Bumbleworks::Ruote do
|
|
310
310
|
described_class.register_participants &nil
|
311
311
|
described_class.dashboard.participant_list.should have(3).item
|
312
312
|
described_class.dashboard.participant_list.map(&:classname).should ==
|
313
|
-
['Bumbleworks::
|
313
|
+
['Bumbleworks::ErrorDispatcher', 'Bumbleworks::EntityInteractor', 'Bumbleworks::StorageParticipant']
|
314
314
|
end
|
315
315
|
end
|
316
316
|
|
317
|
-
describe '.
|
317
|
+
describe '.register_error_dispatcher', dev:true do
|
318
318
|
it 'registers the error handler participant' do
|
319
|
-
described_class.
|
320
|
-
Bumbleworks.dashboard.participant_list.map(&:classname).should include('Bumbleworks::
|
319
|
+
described_class.register_error_dispatcher
|
320
|
+
Bumbleworks.dashboard.participant_list.map(&:classname).should include('Bumbleworks::ErrorDispatcher')
|
321
321
|
end
|
322
322
|
|
323
|
-
it 'it sets the global Ruote on_error to the
|
324
|
-
described_class.
|
325
|
-
Bumbleworks.dashboard.on_error.flatten[2].should == '
|
323
|
+
it 'it sets the global Ruote on_error to the error_dispatcher' do
|
324
|
+
described_class.register_error_dispatcher
|
325
|
+
Bumbleworks.dashboard.on_error.flatten[2].should == 'error_dispatcher'
|
326
326
|
end
|
327
327
|
|
328
|
-
it 'does not override existing
|
328
|
+
it 'does not override existing error_dispatcher' do
|
329
329
|
described_class.register_participants do
|
330
|
-
|
330
|
+
error_dispatcher 'Whatever'
|
331
331
|
end
|
332
|
-
described_class.
|
332
|
+
described_class.register_error_dispatcher
|
333
333
|
Bumbleworks.dashboard.participant_list.map(&:classname).should ==
|
334
|
-
['Bumbleworks::
|
334
|
+
['Bumbleworks::EntityInteractor', 'Whatever', 'Bumbleworks::StorageParticipant']
|
335
335
|
|
336
336
|
end
|
337
337
|
end
|
@@ -369,7 +369,7 @@ describe Bumbleworks::Ruote do
|
|
369
369
|
described_class.dashboard.participant_list.should be_empty
|
370
370
|
described_class.launch('foo')
|
371
371
|
described_class.dashboard.participant_list.should have(1).item
|
372
|
-
described_class.dashboard.participant_list.first.classname.should == 'Bumbleworks::
|
372
|
+
described_class.dashboard.participant_list.first.classname.should == 'Bumbleworks::StorageParticipant'
|
373
373
|
end
|
374
374
|
end
|
375
375
|
|
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.51
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -172,12 +172,12 @@ files:
|
|
172
172
|
- lib/bumbleworks/error_logger.rb
|
173
173
|
- lib/bumbleworks/hash_storage.rb
|
174
174
|
- lib/bumbleworks/participant.rb
|
175
|
-
- lib/bumbleworks/participant/base.rb
|
176
|
-
- lib/bumbleworks/participant/entity_interactor.rb
|
177
|
-
- lib/bumbleworks/participant/error_handler.rb
|
178
|
-
- lib/bumbleworks/participant/local_participant.rb
|
179
|
-
- lib/bumbleworks/participant/storage_participant.rb
|
180
175
|
- lib/bumbleworks/participant_registration.rb
|
176
|
+
- lib/bumbleworks/participants/entity_interactor.rb
|
177
|
+
- lib/bumbleworks/participants/error_dispatcher.rb
|
178
|
+
- lib/bumbleworks/participants/local_participant.rb
|
179
|
+
- lib/bumbleworks/participants/participant.rb
|
180
|
+
- lib/bumbleworks/participants/storage_participant.rb
|
181
181
|
- lib/bumbleworks/process.rb
|
182
182
|
- lib/bumbleworks/process_definition.rb
|
183
183
|
- lib/bumbleworks/rake_tasks.rb
|
@@ -221,7 +221,7 @@ files:
|
|
221
221
|
- spec/lib/bumbleworks/hash_storage_spec.rb
|
222
222
|
- spec/lib/bumbleworks/participant/base_spec.rb
|
223
223
|
- spec/lib/bumbleworks/participant/entity_interactor_spec.rb
|
224
|
-
- spec/lib/bumbleworks/participant/
|
224
|
+
- spec/lib/bumbleworks/participant/error_dispatcher_spec.rb
|
225
225
|
- spec/lib/bumbleworks/participant/local_participant_spec.rb
|
226
226
|
- spec/lib/bumbleworks/participant_registration_spec.rb
|
227
227
|
- spec/lib/bumbleworks/process_definition_spec.rb
|
@@ -256,7 +256,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
256
256
|
version: '0'
|
257
257
|
segments:
|
258
258
|
- 0
|
259
|
-
hash:
|
259
|
+
hash: 3654012293200384530
|
260
260
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
261
261
|
none: false
|
262
262
|
requirements:
|
@@ -265,7 +265,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
265
265
|
version: '0'
|
266
266
|
segments:
|
267
267
|
- 0
|
268
|
-
hash:
|
268
|
+
hash: 3654012293200384530
|
269
269
|
requirements: []
|
270
270
|
rubyforge_project:
|
271
271
|
rubygems_version: 1.8.23
|
@@ -300,7 +300,7 @@ test_files:
|
|
300
300
|
- spec/lib/bumbleworks/hash_storage_spec.rb
|
301
301
|
- spec/lib/bumbleworks/participant/base_spec.rb
|
302
302
|
- spec/lib/bumbleworks/participant/entity_interactor_spec.rb
|
303
|
-
- spec/lib/bumbleworks/participant/
|
303
|
+
- spec/lib/bumbleworks/participant/error_dispatcher_spec.rb
|
304
304
|
- spec/lib/bumbleworks/participant/local_participant_spec.rb
|
305
305
|
- spec/lib/bumbleworks/participant_registration_spec.rb
|
306
306
|
- spec/lib/bumbleworks/process_definition_spec.rb
|
@@ -1,29 +0,0 @@
|
|
1
|
-
module Bumbleworks
|
2
|
-
module Participant
|
3
|
-
class EntityInteractor < Bumbleworks::Participant::Base
|
4
|
-
def on_workitem
|
5
|
-
method_name = workitem.fields['params']['method'] ||
|
6
|
-
workitem.fields['params']['to'] ||
|
7
|
-
workitem.fields['params']['for']
|
8
|
-
result_field = workitem.fields['params']['and_save_as']
|
9
|
-
arguments = workitem.fields['params']['arguments'] ||
|
10
|
-
workitem.fields['params']['with']
|
11
|
-
result = call_method(method_name, :save_as => result_field, :args => arguments)
|
12
|
-
reply
|
13
|
-
end
|
14
|
-
|
15
|
-
def call_method(method_name, options = {})
|
16
|
-
result = if options[:args]
|
17
|
-
options[:args] = [options[:args]] if options[:args].is_a?(Hash)
|
18
|
-
entity.send(method_name, *options[:args])
|
19
|
-
else
|
20
|
-
entity.send(method_name)
|
21
|
-
end
|
22
|
-
if result && options[:save_as]
|
23
|
-
workitem.fields[options[:save_as]] = result
|
24
|
-
end
|
25
|
-
result
|
26
|
-
end
|
27
|
-
end
|
28
|
-
end
|
29
|
-
end
|
@@ -1,14 +0,0 @@
|
|
1
|
-
module Bumbleworks
|
2
|
-
module Participant
|
3
|
-
class ErrorHandler < Bumbleworks::Participant::Base
|
4
|
-
def on_workitem
|
5
|
-
return if (error_handlers = Bumbleworks.error_handlers).empty?
|
6
|
-
|
7
|
-
error_handlers.each do |error_handler|
|
8
|
-
error_handler.new(workitem).on_error
|
9
|
-
end
|
10
|
-
reply
|
11
|
-
end
|
12
|
-
end
|
13
|
-
end
|
14
|
-
end
|