bumbleworks 0.0.31 → 0.0.32

Sign up to get free protection for your applications and to get access to all the features.
@@ -9,14 +9,7 @@ module Bumbleworks
9
9
 
10
10
  class << self
11
11
  def dashboard(options = {})
12
- @dashboard ||= begin
13
- context = if options[:start_worker] == true
14
- ::Ruote::Worker.new(storage)
15
- else
16
- storage
17
- end
18
- ::Ruote::Dashboard.new(context)
19
- end
12
+ @dashboard ||= ::Ruote::Dashboard.new(storage)
20
13
  end
21
14
 
22
15
  # Start a worker, which will begin polling for messages in
@@ -35,11 +28,14 @@ module Bumbleworks
35
28
  # exits.
36
29
  #
37
30
  def start_worker!(options = {})
38
- @dashboard = nil
39
- dashboard(:start_worker => true)
40
31
  dashboard.noisy = options[:verbose] == true
41
- dashboard.join if options[:join] == true
42
- dashboard.worker
32
+ worker = ::Ruote::Worker.new(dashboard.context)
33
+ if options[:join] == true
34
+ worker.run
35
+ else
36
+ worker.run_in_thread
37
+ end
38
+ worker
43
39
  end
44
40
 
45
41
  def launch(name, *args)
@@ -61,7 +57,7 @@ module Bumbleworks
61
57
  while dashboard.processes.count > 0
62
58
  if (Time.now - start_time) > options[:timeout]
63
59
  error_type = options[:method] == :cancel ? CancelTimeout : KillTimeout
64
- raise error_type, "Process #{options[:method]} taking too long - #{dashboard.processes.count} processes remain"
60
+ raise error_type, "Process #{options[:method]} taking too long - #{dashboard.processes.count} processes remain. Errors: #{dashboard.errors}"
65
61
  end
66
62
  sleep 0.1
67
63
  end
@@ -1,3 +1,3 @@
1
1
  module Bumbleworks
2
- VERSION = "0.0.31"
2
+ VERSION = "0.0.32"
3
3
  end
@@ -88,10 +88,6 @@ describe Bumbleworks::Ruote do
88
88
  it 'does not start a worker by default' do
89
89
  described_class.dashboard.worker.should be_nil
90
90
  end
91
-
92
- it 'starts a worker if :start_worker option is true' do
93
- described_class.dashboard(:start_worker => true).worker.should_not be_nil
94
- end
95
91
  end
96
92
 
97
93
  describe '.start_worker!' do
@@ -102,23 +98,20 @@ describe Bumbleworks::Ruote do
102
98
  described_class.dashboard.worker.should == new_worker
103
99
  end
104
100
 
105
- it 'joins current thread if :join option is true' do
106
- ::Ruote::Dashboard.stub(:new).and_return(dash_double = double('dash', :worker => nil))
107
- dash_double.should_receive(:noisy=).with(false)
108
- dash_double.should_receive(:join)
101
+ it 'runs in current thread if :join option is true' do
102
+ ::Ruote::Worker.stub(:new).and_return(worker_double = double('worker'))
103
+ worker_double.should_receive(:run)
109
104
  described_class.start_worker!(:join => true)
110
105
  end
111
106
 
112
- it 'returns if :join option not true' do
113
- ::Ruote::Dashboard.stub(:new).and_return(dash_double = double('dash', :worker => nil))
114
- dash_double.should_receive(:noisy=).with(false)
115
- dash_double.should_receive(:join).never
116
- described_class.start_worker!
107
+ it 'runs in new thread and returns worker if :join option not true' do
108
+ ::Ruote::Worker.stub(:new).and_return(worker_double = double('worker'))
109
+ worker_double.should_receive(:run_in_thread)
110
+ described_class.start_worker!.should == worker_double
117
111
  end
118
112
 
119
113
  it 'sets dashboard to noisy if :verbose option true' do
120
- ::Ruote::Dashboard.stub(:new).and_return(dash_double = double('dash', :worker => nil))
121
- dash_double.should_receive(:noisy=).with(true)
114
+ described_class.dashboard.should_receive(:noisy=).with(true)
122
115
  described_class.start_worker!(:verbose => true)
123
116
  end
124
117
  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.31
4
+ version: 0.0.32
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: 2013-08-12 00:00:00.000000000 Z
15
+ date: 2013-08-13 00:00:00.000000000 Z
16
16
  dependencies:
17
17
  - !ruby/object:Gem::Dependency
18
18
  name: ruote