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.
@@ -1,10 +1,5 @@
1
- require "bumbleworks/participant/storage_participant"
2
- require "bumbleworks/participant/local_participant"
3
- require "bumbleworks/participant/base"
4
- require "bumbleworks/participant/error_handler"
5
- require "bumbleworks/participant/entity_interactor"
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
@@ -0,0 +1,9 @@
1
+ require "ruote/part/local_participant"
2
+ require "bumbleworks/workitem_entity_storage"
3
+
4
+ module Bumbleworks
5
+ module LocalParticipant
6
+ include ::Ruote::LocalParticipant
7
+ include WorkitemEntityStorage
8
+ end
9
+ end
@@ -0,0 +1,9 @@
1
+ module Bumbleworks
2
+ class Participant
3
+ include LocalParticipant
4
+
5
+ def on_cancel
6
+ # default no-op method
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,9 @@
1
+ module Bumbleworks
2
+ class StorageParticipant < ::Ruote::StorageParticipant
3
+ def on_workitem
4
+ return_value = super
5
+ Bumbleworks::Task.new(self[workitem.sid]).on_dispatch
6
+ return return_value
7
+ end
8
+ end
9
+ end
@@ -29,7 +29,7 @@ module Bumbleworks
29
29
  #
30
30
  def start_worker!(options = {})
31
31
  set_up_storage_history
32
- register_error_handler
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
- register_error_handler
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::Participant::EntityInteractor", {}]])
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 register_error_handler
117
- unless dashboard.participant_list.any? { |part| part.regex == '^error_handler_participant$' }
118
- error_handler_participant = ::Ruote::ParticipantEntry.new(['^error_handler_participant$', ["Bumbleworks::Participant::ErrorHandler", {}]])
119
- dashboard.participant_list = dashboard.participant_list.unshift(error_handler_participant)
120
- dashboard.on_error = 'error_handler_participant'
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::Participant::StorageParticipant"].include?(last_participant.classname)
134
- catchall = ::Ruote::ParticipantEntry.new(["^.+$", ["Bumbleworks::Participant::StorageParticipant", {}]])
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
@@ -1,3 +1,3 @@
1
1
  module Bumbleworks
2
- VERSION = "0.0.50"
2
+ VERSION = "0.0.51"
3
3
  end
@@ -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::Participant::ErrorHandler',
16
- 'Bumbleworks::Participant::EntityInteractor',
15
+ 'Bumbleworks::ErrorDispatcher',
16
+ 'Bumbleworks::EntityInteractor',
17
17
  'HoneyParticipant',
18
18
  'MolassesParticipant',
19
- 'Bumbleworks::Participant::StorageParticipant'
19
+ 'Bumbleworks::StorageParticipant'
20
20
  ]
21
21
  end
22
22
 
@@ -1,6 +1,6 @@
1
- describe Bumbleworks::Participant::Base do
2
- it 'includes Bumbleworks::Participant::LocalParticipant' do
3
- described_class.included_modules.should include(Bumbleworks::Participant::LocalParticipant)
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::Participant::EntityInteractor do
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 }
@@ -1,4 +1,4 @@
1
- describe Bumbleworks::Participant::ErrorHandler do
1
+ describe Bumbleworks::ErrorDispatcher do
2
2
  describe '#on_workitem' do
3
3
  let(:workitem) { double('workitem') }
4
4
  let(:instances) { [double(:on_error => nil), double(:on_error => nil)] }
@@ -1,4 +1,4 @@
1
- describe Bumbleworks::Participant::LocalParticipant do
1
+ describe Bumbleworks::LocalParticipant do
2
2
  it 'includes Ruote::LocalParticipant' do
3
3
  described_class.included_modules.should include(Ruote::LocalParticipant)
4
4
  end
@@ -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(:register_error_handler)
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 error_handler_participant if already registered' do
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::Participant::ErrorHandler',
239
- 'Bumbleworks::Participant::EntityInteractor',
240
- 'Bumbleworks::Participant::StorageParticipant'
238
+ 'Bumbleworks::ErrorDispatcher',
239
+ 'Bumbleworks::EntityInteractor',
240
+ 'Bumbleworks::StorageParticipant'
241
241
  ]
242
- Bumbleworks.dashboard.on_error.flatten[2].should == 'error_handler_participant'
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 &registration_block
285
285
  described_class.dashboard.participant_list.should have(6).items
286
286
  described_class.dashboard.participant_list.map(&:classname).should == [
287
- 'Bumbleworks::Participant::ErrorHandler',
288
- 'Bumbleworks::Participant::EntityInteractor',
287
+ 'Bumbleworks::ErrorDispatcher',
288
+ 'Bumbleworks::EntityInteractor',
289
289
  'BeesHoney', 'MapleSyrup', 'NewCatchall',
290
- 'Bumbleworks::Participant::StorageParticipant'
290
+ 'Bumbleworks::StorageParticipant'
291
291
  ]
292
292
  end
293
293
 
@@ -301,7 +301,7 @@ describe Bumbleworks::Ruote do
301
301
  described_class.register_participants &registration_block
302
302
  described_class.dashboard.participant_list.should have(4).items
303
303
  described_class.dashboard.participant_list.map(&:classname).should == [
304
- 'Bumbleworks::Participant::ErrorHandler', 'Bumbleworks::Participant::EntityInteractor', 'BeesHoney', 'Ruote::StorageParticipant'
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::Participant::ErrorHandler', 'Bumbleworks::Participant::EntityInteractor', 'Bumbleworks::Participant::StorageParticipant']
313
+ ['Bumbleworks::ErrorDispatcher', 'Bumbleworks::EntityInteractor', 'Bumbleworks::StorageParticipant']
314
314
  end
315
315
  end
316
316
 
317
- describe '.register_error_handler', dev:true do
317
+ describe '.register_error_dispatcher', dev:true do
318
318
  it 'registers the error handler participant' do
319
- described_class.register_error_handler
320
- Bumbleworks.dashboard.participant_list.map(&:classname).should include('Bumbleworks::Participant::ErrorHandler')
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 error_handler_participant' do
324
- described_class.register_error_handler
325
- Bumbleworks.dashboard.on_error.flatten[2].should == 'error_handler_participant'
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 error_handler_participant' do
328
+ it 'does not override existing error_dispatcher' do
329
329
  described_class.register_participants do
330
- error_handler_participant 'Whatever'
330
+ error_dispatcher 'Whatever'
331
331
  end
332
- described_class.register_error_handler
332
+ described_class.register_error_dispatcher
333
333
  Bumbleworks.dashboard.participant_list.map(&:classname).should ==
334
- ['Bumbleworks::Participant::EntityInteractor', 'Whatever', 'Bumbleworks::Participant::StorageParticipant']
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::Participant::StorageParticipant'
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.50
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/error_handler_spec.rb
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: 3856006689923069850
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: 3856006689923069850
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/error_handler_spec.rb
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,11 +0,0 @@
1
- module Bumbleworks
2
- module Participant
3
- class Base
4
- include LocalParticipant
5
-
6
- def on_cancel
7
- # default no-op method
8
- end
9
- end
10
- end
11
- end
@@ -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
@@ -1,11 +0,0 @@
1
- require "ruote/part/local_participant"
2
- require "bumbleworks/workitem_entity_storage"
3
-
4
- module Bumbleworks
5
- module Participant
6
- module LocalParticipant
7
- include ::Ruote::LocalParticipant
8
- include WorkitemEntityStorage
9
- end
10
- end
11
- end
@@ -1,11 +0,0 @@
1
- module Bumbleworks
2
- module Participant
3
- class StorageParticipant < ::Ruote::StorageParticipant
4
- def on_workitem
5
- return_value = super
6
- Bumbleworks::Task.new(self[workitem.sid]).on_dispatch
7
- return return_value
8
- end
9
- end
10
- end
11
- end