bumbleworks 0.0.74 → 0.0.76

Sign up to get free protection for your applications and to get access to all the features.
Files changed (50) hide show
  1. checksums.yaml +7 -0
  2. data/.rspec +1 -1
  3. data/.ruby-version +1 -1
  4. data/bumbleworks.gemspec +2 -2
  5. data/lib/bumbleworks.rb +1 -0
  6. data/lib/bumbleworks/expression.rb +12 -1
  7. data/lib/bumbleworks/process.rb +10 -0
  8. data/lib/bumbleworks/process/error_record.rb +14 -0
  9. data/lib/bumbleworks/schedule.rb +58 -0
  10. data/lib/bumbleworks/task.rb +2 -1
  11. data/lib/bumbleworks/task/finder.rb +4 -0
  12. data/lib/bumbleworks/version.rb +1 -1
  13. data/lib/bumbleworks/workitem.rb +4 -0
  14. data/spec/fixtures/schedules.rb +40 -0
  15. data/spec/integration/entity_spec.rb +7 -7
  16. data/spec/integration/example_configurations_spec.rb +5 -5
  17. data/spec/integration/history_storage_spec.rb +9 -9
  18. data/spec/integration/sample_application_spec.rb +15 -15
  19. data/spec/lib/bumbleworks/configuration_spec.rb +52 -52
  20. data/spec/lib/bumbleworks/entity_spec.rb +66 -68
  21. data/spec/lib/bumbleworks/error_handler_spec.rb +1 -1
  22. data/spec/lib/bumbleworks/error_logger_spec.rb +5 -5
  23. data/spec/lib/bumbleworks/expression_spec.rb +34 -12
  24. data/spec/lib/bumbleworks/hash_storage_spec.rb +2 -2
  25. data/spec/lib/bumbleworks/participant/base_spec.rb +1 -1
  26. data/spec/lib/bumbleworks/participant/entity_interactor_spec.rb +20 -20
  27. data/spec/lib/bumbleworks/participant/error_dispatcher_spec.rb +3 -3
  28. data/spec/lib/bumbleworks/participant/local_participant_spec.rb +1 -1
  29. data/spec/lib/bumbleworks/participant_registration_spec.rb +4 -4
  30. data/spec/lib/bumbleworks/process/error_record_spec.rb +13 -0
  31. data/spec/lib/bumbleworks/process_definition_spec.rb +30 -24
  32. data/spec/lib/bumbleworks/process_spec.rb +86 -54
  33. data/spec/lib/bumbleworks/ruote/exp/broadcast_event_expression_spec.rb +2 -2
  34. data/spec/lib/bumbleworks/ruote/exp/wait_for_event_expression_spec.rb +4 -4
  35. data/spec/lib/bumbleworks/ruote_spec.rb +73 -71
  36. data/spec/lib/bumbleworks/schedule_spec.rb +124 -0
  37. data/spec/lib/bumbleworks/simple_logger_spec.rb +8 -8
  38. data/spec/lib/bumbleworks/storage_adapter_spec.rb +16 -16
  39. data/spec/lib/bumbleworks/support_spec.rb +23 -19
  40. data/spec/lib/bumbleworks/task/finder_spec.rb +46 -46
  41. data/spec/lib/bumbleworks/task_spec.rb +188 -167
  42. data/spec/lib/bumbleworks/tracker_spec.rb +41 -42
  43. data/spec/lib/bumbleworks/tree_builder_spec.rb +9 -7
  44. data/spec/lib/bumbleworks/user_spec.rb +35 -35
  45. data/spec/lib/bumbleworks/workitem_entity_storage_spec.rb +5 -5
  46. data/spec/lib/bumbleworks/workitem_spec.rb +28 -17
  47. data/spec/lib/bumbleworks_spec.rb +57 -51
  48. data/spec/spec_helper.rb +0 -1
  49. data/spec/support/shared_examples.rb +3 -3
  50. metadata +35 -54
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: a72f385d9eb663aa79fbdfac3f6d685ef5252a09
4
+ data.tar.gz: 9f52631aee6181e1cb998878660d1d4a9a14bffd
5
+ SHA512:
6
+ metadata.gz: 2d830cfb32aaf2c7a3e80356ee9d589b0e31f282dd4ce913f0f765b9d348b1fb2ea50fa608c9b23d751d5c439d5434f7bf15139ce1a34c28aa3d8328315a4fbe
7
+ data.tar.gz: 704f70271d7235a25911a3bc4fdb6c90a191b2e5fcbb0f80b0dca478d8aef8dad7332f7b87eaf6e9e6cd76c9f6ffd81a771059d23fe0bab20bc785b1953948b5
data/.rspec CHANGED
@@ -1,3 +1,3 @@
1
1
  --color
2
- --format=nested
2
+ --format documentation
3
3
  --require spec_helper
data/.ruby-version CHANGED
@@ -1 +1 @@
1
- 1.9.3-p392
1
+ 2.1.1
data/bumbleworks.gemspec CHANGED
@@ -22,9 +22,9 @@ Gem::Specification.new do |spec|
22
22
 
23
23
  spec.add_development_dependency "bundler", "~> 1.3"
24
24
  spec.add_development_dependency "rake"
25
- spec.add_development_dependency 'rspec'
25
+ spec.add_development_dependency 'rspec', '~> 3.0'
26
26
  spec.add_development_dependency 'watchr'
27
- spec.add_development_dependency 'debugger'
27
+ spec.add_development_dependency 'pry'
28
28
  spec.add_development_dependency 'sqlite3'
29
29
  spec.add_development_dependency 'simplecov'
30
30
  end
data/lib/bumbleworks.rb CHANGED
@@ -14,6 +14,7 @@ require "bumbleworks/entity"
14
14
  require "bumbleworks/participant"
15
15
  require "bumbleworks/workitem"
16
16
  require "bumbleworks/tracker"
17
+ require "bumbleworks/schedule"
17
18
  require "bumbleworks/user"
18
19
 
19
20
  # default implementations
@@ -1,6 +1,13 @@
1
1
  module Bumbleworks
2
2
  class Expression
3
- attr_reader :expid
3
+ attr_reader :expid, :fei
4
+
5
+ class << self
6
+ def from_fei(fei)
7
+ fexp = ::Ruote::Exp::FlowExpression.fetch(Bumbleworks.dashboard.context, fei)
8
+ new(fexp)
9
+ end
10
+ end
4
11
 
5
12
  def initialize(flow_expression)
6
13
  @flow_expression = flow_expression
@@ -8,6 +15,10 @@ module Bumbleworks
8
15
  @expid = @fei.expid
9
16
  end
10
17
 
18
+ def ==(other)
19
+ @fei == other.fei
20
+ end
21
+
11
22
  # Returns a Bumbleworks::Process instance for the expression's
12
23
  # wfid; effectively, the process instance this expression is
13
24
  # a part of.
@@ -40,6 +40,10 @@ module Bumbleworks
40
40
  self
41
41
  end
42
42
 
43
+ def running?
44
+ !process_status.nil?
45
+ end
46
+
43
47
  alias_method :wfid, :id
44
48
 
45
49
  def <=>(other)
@@ -104,6 +108,12 @@ module Bumbleworks
104
108
  }
105
109
  end
106
110
 
111
+ def schedules
112
+ @schedules ||= Bumbleworks.dashboard.schedules(id).map { |schedule_hash|
113
+ Bumbleworks::Schedule.new(schedule_hash)
114
+ }
115
+ end
116
+
107
117
  def all_subscribed_tags
108
118
  @all_subscribed_tags ||= trackers.inject({ :global => [] }) do |memo, t|
109
119
  if t.global?
@@ -1,11 +1,25 @@
1
1
  module Bumbleworks
2
2
  class Process
3
3
  class ErrorRecord
4
+ attr_reader :process_error
5
+
4
6
  # The initializer takes a Ruote::ProcessError instance.
5
7
  def initialize(process_error)
6
8
  @process_error = process_error
7
9
  end
8
10
 
11
+ # Replays the error's process at the point where the error occurred.
12
+ # Should only be called when the cause of the error has been fixed,
13
+ # since otherwise this will just cause the error to show up again.
14
+ def replay
15
+ Bumbleworks.dashboard.replay_at_error(@process_error)
16
+ end
17
+
18
+ # Returns the workitem at the position where this error occurred.
19
+ def workitem
20
+ @process_error.workitem
21
+ end
22
+
9
23
  # Returns the FlowExpressionId of the expression where this error
10
24
  # occurred.
11
25
  def fei
@@ -0,0 +1,58 @@
1
+ module Bumbleworks
2
+ class Schedule
3
+ attr_reader :id, :original_hash
4
+
5
+ class << self
6
+ def all
7
+ Bumbleworks.dashboard.schedules.map do |hsh|
8
+ new(hsh)
9
+ end
10
+ end
11
+
12
+ def count
13
+ all.count
14
+ end
15
+ end
16
+
17
+ def initialize(schedule_hash)
18
+ @original_hash = schedule_hash
19
+ @id = @original_hash['_id']
20
+ end
21
+
22
+ def ==(other)
23
+ @id == other.id
24
+ end
25
+
26
+ def wfid
27
+ @original_hash['wfid']
28
+ end
29
+
30
+ def process
31
+ Bumbleworks::Process.new(wfid)
32
+ end
33
+
34
+ def expression
35
+ Bumbleworks::Expression.from_fei(@original_hash['owner'])
36
+ end
37
+
38
+ def repeating?
39
+ ['cron', 'every'].include? expression.tree[0]
40
+ end
41
+
42
+ def once?
43
+ !repeating?
44
+ end
45
+
46
+ def next_at
47
+ Time.parse(@original_hash['at'])
48
+ end
49
+
50
+ def original_plan
51
+ @original_hash['original']
52
+ end
53
+
54
+ def test_clause
55
+ expression.tree[1]['test']
56
+ end
57
+ end
58
+ end
@@ -12,7 +12,7 @@ module Bumbleworks
12
12
  class AvailabilityTimeout < StandardError; end
13
13
 
14
14
  extend Forwardable
15
- delegate [:sid, :fei, :fields, :params, :participant_name, :wfid, :wf_name] => :@workitem
15
+ delegate [:sid, :fei, :fields, :dispatched_at, :params, :participant_name, :wfid, :wf_name] => :@workitem
16
16
  attr_reader :nickname, :workitem
17
17
  alias_method :id, :sid
18
18
 
@@ -209,6 +209,7 @@ module Bumbleworks
209
209
 
210
210
  def update_workitem
211
211
  storage_participant.update(@workitem)
212
+ reload
212
213
  end
213
214
 
214
215
  def proceed_workitem
@@ -184,6 +184,10 @@ module Bumbleworks
184
184
  to_a
185
185
  end
186
186
 
187
+ def size
188
+ all.size
189
+ end
190
+
187
191
  def empty?
188
192
  !any?
189
193
  end
@@ -1,3 +1,3 @@
1
1
  module Bumbleworks
2
- VERSION = "0.0.74"
2
+ VERSION = "0.0.76"
3
3
  end
@@ -45,6 +45,10 @@ module Bumbleworks
45
45
  }
46
46
  end
47
47
 
48
+ def tokenized_entity_type
49
+ Bumbleworks::Support.tokenize(entity_type)
50
+ end
51
+
48
52
  def entity_name
49
53
  fields = entity_fields(:titleize => true)
50
54
  "#{fields[:type]} #{fields[:identifier]}"
@@ -0,0 +1,40 @@
1
+ def fake_schedules
2
+ [
3
+ {
4
+ "_id" => "at-0_0!d65a8006da6d9025d48fa916071a6dc1!20140710-1001-dirisoma-rebadihe-20140718000000",
5
+ "flavour" => "at",
6
+ "original" => "2014-07-18 04:00:00",
7
+ "at" => "2014-07-18 04:00:00.000000 UTC",
8
+ "wfid" => "20140710-1001-dirisoma-rebadihe",
9
+ "put_at" => "2014-07-10 10:01:48.947039 UTC",
10
+ "action" => "reply",
11
+ "type" => nil,
12
+ "owner" => :a_flow_expression,
13
+ "target" => :a_flow_expression
14
+ },
15
+ {
16
+ "_id" => "cron-0_0!48ec5a9db7d4c61da0ebaa968bd552c3!20140710-1016-nodemika-kudatsufu-20140710101857",
17
+ "flavour" => "cron",
18
+ "original" => "1m",
19
+ "at" => "2014-07-10 10:18:57.409405 UTC",
20
+ "wfid" => "20140710-1016-nodemika-kudatsufu",
21
+ "put_at" => "2014-07-10 10:17:57.409719 UTC",
22
+ "action" => "reply",
23
+ "type" => nil,
24
+ "owner" => :a_flow_expression,
25
+ "target" => :a_flow_expression
26
+ },
27
+ {
28
+ "_id" => "cron-0_0!9103b81d6b2cc198ec44b1c7c6461d1e!20140710-1023-dobabako-jabufuso-20140713111500",
29
+ "flavour" => "cron",
30
+ "original" => "15 4 * * sun",
31
+ "at" => "2014-07-13 11:15:00.000000 UTC",
32
+ "wfid" => "20140710-1023-dobabako-jabufuso",
33
+ "put_at" => "2014-07-10 10:23:24.027149 UTC",
34
+ "action" => "reply",
35
+ "type" => nil,
36
+ "owner" => :a_flow_expression,
37
+ "target" => :a_flow_expression
38
+ }
39
+ ]
40
+ end
@@ -14,7 +14,7 @@ describe 'Entity Module' do
14
14
  Bumbleworks.entity_classes = [:geese]
15
15
  FirstNewClass = Class.new { include Bumbleworks::Entity }
16
16
  SecondNewClass = Class.new { include Bumbleworks::Entity }
17
- Bumbleworks.entity_classes.should == [:geese, FirstNewClass, SecondNewClass]
17
+ expect(Bumbleworks.entity_classes).to eq([:geese, FirstNewClass, SecondNewClass])
18
18
  end
19
19
  end
20
20
 
@@ -24,23 +24,23 @@ describe 'Entity Module' do
24
24
  process = rainbow_loom.launch_process(:make_honey)
25
25
  Bumbleworks.dashboard.wait_for(:dave)
26
26
  task = Bumbleworks::Task.for_role('dave').first
27
- task.entity.should == rainbow_loom
28
- process.entity.should == rainbow_loom
27
+ expect(task.entity).to eq(rainbow_loom)
28
+ expect(process.entity).to eq(rainbow_loom)
29
29
  end
30
30
 
31
31
  it 'launching links processes with identifiers' do
32
32
  rainbow_loom = RainbowLoom.new('12345')
33
33
  process = rainbow_loom.launch_process(:make_honey)
34
- rainbow_loom.processes_by_name.should == {
34
+ expect(rainbow_loom.processes_by_name).to eq({
35
35
  :make_honey => process,
36
36
  :make_molasses => nil
37
- }
37
+ })
38
38
  end
39
39
 
40
40
  it 'persists process identifier' do
41
41
  rainbow_loom = RainbowLoom.new('12345')
42
42
  process = rainbow_loom.launch_process(:make_honey)
43
- rainbow_loom.make_honey_process_identifier.should == process.wfid
43
+ expect(rainbow_loom.make_honey_process_identifier).to eq(process.wfid)
44
44
  end
45
45
  end
46
46
 
@@ -53,7 +53,7 @@ describe 'Entity Module' do
53
53
  rainbow_loom = RainbowLoom.new('12345')
54
54
  process = Bumbleworks.launch!('here_we_go', :entity => rainbow_loom)
55
55
  Bumbleworks.dashboard.wait_for(:critic)
56
- process.tasks.first['yum'].should == "2 and orange"
56
+ expect(process.tasks.first['yum']).to eq("2 and orange")
57
57
  end
58
58
  end
59
59
  end
@@ -7,31 +7,31 @@ describe Bumbleworks::Configuration do
7
7
  describe '#root' do
8
8
  it 'returns configured root' do
9
9
  load default_initializer
10
- Bumbleworks.root.should == default_app_path
10
+ expect(Bumbleworks.root).to eq(default_app_path)
11
11
  end
12
12
  end
13
13
 
14
14
  describe '#definitions_directory' do
15
15
  it 'returns specified directory when set in configuration' do
16
16
  load specified_initializer
17
- Bumbleworks.definitions_directory.should == File.join(specified_app_path, 'specific_directory', 'definitions')
17
+ expect(Bumbleworks.definitions_directory).to eq(File.join(specified_app_path, 'specific_directory', 'definitions'))
18
18
  end
19
19
 
20
20
  it 'returns default directory when not set in configuration' do
21
21
  load default_initializer
22
- Bumbleworks.definitions_directory.should == File.join(default_app_path, 'process_definitions')
22
+ expect(Bumbleworks.definitions_directory).to eq(File.join(default_app_path, 'process_definitions'))
23
23
  end
24
24
  end
25
25
 
26
26
  describe '#participants_directory' do
27
27
  it 'returns specified directory when set in configuration' do
28
28
  load specified_initializer
29
- Bumbleworks.participants_directory.should == File.join(specified_app_path, 'specific_directory', 'participants')
29
+ expect(Bumbleworks.participants_directory).to eq(File.join(specified_app_path, 'specific_directory', 'participants'))
30
30
  end
31
31
 
32
32
  it 'returns default directory when not set in configuration' do
33
33
  load default_initializer
34
- Bumbleworks.participants_directory.should == File.join(default_app_path, 'participants')
34
+ expect(Bumbleworks.participants_directory).to eq(File.join(default_app_path, 'participants'))
35
35
  end
36
36
  end
37
37
  end
@@ -11,20 +11,20 @@ describe 'History storage' do
11
11
 
12
12
  context 'when storage allows storing history' do
13
13
  before :each do
14
- Bumbleworks.stub(:storage_adapter => HashStorageWithHistory)
14
+ allow(Bumbleworks).to receive_messages(:storage_adapter => HashStorageWithHistory)
15
15
  load File.join(app_root, 'full_initializer.rb')
16
16
  end
17
17
 
18
18
  it 'uses storage for history' do
19
- Bumbleworks.dashboard.history.should be_a(::Ruote::StorageHistory)
19
+ expect(Bumbleworks.dashboard.history).to be_a(::Ruote::StorageHistory)
20
20
  end
21
21
 
22
22
  it 'keeps history of messages' do
23
- Bumbleworks::Ruote.storage.get_many('history').should be_empty
23
+ expect(Bumbleworks::Ruote.storage.get_many('history')).to be_empty
24
24
  process = Bumbleworks.launch!('make_honey')
25
25
  Bumbleworks.dashboard.wait_for(:dave)
26
- Bumbleworks::Ruote.storage.get_many('history').should_not be_empty
27
- Bumbleworks.dashboard.history.wfids.should include(process.wfid)
26
+ expect(Bumbleworks::Ruote.storage.get_many('history')).not_to be_empty
27
+ expect(Bumbleworks.dashboard.history.wfids).to include(process.wfid)
28
28
  end
29
29
  end
30
30
 
@@ -34,15 +34,15 @@ describe 'History storage' do
34
34
  end
35
35
 
36
36
  it 'does not use storage for history' do
37
- Bumbleworks.dashboard.history.should be_a(::Ruote::DefaultHistory)
37
+ expect(Bumbleworks.dashboard.history).to be_a(::Ruote::DefaultHistory)
38
38
  end
39
39
 
40
40
  it 'keeps history of messages' do
41
- Bumbleworks.dashboard.history.all.should be_empty
41
+ expect(Bumbleworks.dashboard.history.all).to be_empty
42
42
  process = Bumbleworks.launch!('make_honey')
43
43
  Bumbleworks.dashboard.wait_for(:dave)
44
- Bumbleworks.dashboard.history.all.should_not be_empty
45
- Bumbleworks.dashboard.history.wfids.should include(process.wfid)
44
+ expect(Bumbleworks.dashboard.history.all).not_to be_empty
45
+ expect(Bumbleworks.dashboard.history.wfids).to include(process.wfid)
46
46
  end
47
47
  end
48
48
  end
@@ -9,27 +9,27 @@ describe 'Bumbleworks Sample Application' do
9
9
 
10
10
  describe 'initializer' do
11
11
  it 'registers participants' do
12
- Bumbleworks.dashboard.participant_list.should have(5).items
13
- Bumbleworks.dashboard.participant_list.map(&:classname).should == [
12
+ expect(Bumbleworks.dashboard.participant_list.size).to eq(5)
13
+ expect(Bumbleworks.dashboard.participant_list.map(&:classname)).to eq([
14
14
  'Bumbleworks::ErrorDispatcher',
15
15
  'Bumbleworks::EntityInteractor',
16
16
  'HoneyParticipant',
17
17
  'MolassesParticipant',
18
18
  'Bumbleworks::StorageParticipant'
19
- ]
19
+ ])
20
20
  end
21
21
 
22
22
  it 'loads process definitions' do
23
- Bumbleworks.dashboard.variables['make_honey'].should == ["define",
24
- {"name"=>"make_honey"}, [["dave", {"task"=>"make_some_honey"}, []]]]
25
- Bumbleworks.dashboard.variables['garbage_collector'].should == ["define",
26
- {"name"=>"garbage_collector"}, [["george", {"ref"=>"garbage collector"}, []]]]
23
+ expect(Bumbleworks.dashboard.variables['make_honey']).to eq(["define",
24
+ {"name"=>"make_honey"}, [["dave", {"task"=>"make_some_honey"}, []]]])
25
+ expect(Bumbleworks.dashboard.variables['garbage_collector']).to eq(["define",
26
+ {"name"=>"garbage_collector"}, [["george", {"ref"=>"garbage collector"}, []]]])
27
27
 
28
- Bumbleworks.dashboard.variables['make_molasses'].should == ["define",
28
+ expect(Bumbleworks.dashboard.variables['make_molasses']).to eq(["define",
29
29
  {"name"=>"make_molasses"},
30
30
  [["concurrence",
31
31
  {},
32
- [["dave", {"task"=>"make_some_molasses"}, []], ["sam", {"task"=>"taste_that_molasses"}, []]]]]]
32
+ [["dave", {"task"=>"make_some_molasses"}, []], ["sam", {"task"=>"taste_that_molasses"}, []]]]]])
33
33
  end
34
34
  end
35
35
 
@@ -37,15 +37,15 @@ describe 'Bumbleworks Sample Application' do
37
37
  it 'waits for first task in catchall participant' do
38
38
  Bumbleworks.launch!('make_honey')
39
39
  Bumbleworks.dashboard.wait_for(:dave)
40
- Bumbleworks::Task.all.should have(1).item
40
+ expect(Bumbleworks::Task.size).to eq(1)
41
41
  end
42
42
 
43
43
  it 'creates tasks for concurrent workflows' do
44
44
  Bumbleworks.launch!('make_molasses')
45
45
  Bumbleworks.dashboard.wait_for(:dave)
46
- Bumbleworks::Task.all.should have(2).item
47
- Bumbleworks::Task.for_role('dave').should have(1).item
48
- Bumbleworks::Task.for_role('sam').should have(1).item
46
+ expect(Bumbleworks::Task.size).to eq(2)
47
+ expect(Bumbleworks::Task.for_role('dave').size).to eq(1)
48
+ expect(Bumbleworks::Task.for_role('sam').size).to eq(1)
49
49
  end
50
50
  end
51
51
 
@@ -55,7 +55,7 @@ describe 'Bumbleworks Sample Application' do
55
55
  Bumbleworks.dashboard.wait_for(:dave)
56
56
  task = Bumbleworks::Task.for_role('dave').first
57
57
  task.update('happening' => 'update')
58
- task['what_happened'].should == 'update'
58
+ expect(task['what_happened']).to eq('update')
59
59
  end
60
60
  end
61
61
 
@@ -64,7 +64,7 @@ describe 'Bumbleworks Sample Application' do
64
64
  Bumbleworks.launch!('make_honey')
65
65
  Bumbleworks.dashboard.wait_for(:dave)
66
66
  task = Bumbleworks::Task.for_role('dave').first
67
- task['i_was_dispatched'].should == 'yes_i_was'
67
+ expect(task['i_was_dispatched']).to eq('yes_i_was')
68
68
  end
69
69
  end
70
70
  end