bumbleworks 0.0.47 → 0.0.48
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/configuration.rb +11 -0
- data/lib/bumbleworks/ruote.rb +1 -1
- data/lib/bumbleworks/storage_adapter.rb +4 -3
- data/lib/bumbleworks/version.rb +1 -1
- data/spec/lib/bumbleworks/configuration_spec.rb +11 -0
- data/spec/lib/bumbleworks/ruote_spec.rb +3 -1
- data/spec/lib/bumbleworks/storage_adapter_spec.rb +5 -5
- metadata +1 -1
@@ -84,6 +84,16 @@ module Bumbleworks
|
|
84
84
|
#
|
85
85
|
define_setting :storage_adapter
|
86
86
|
|
87
|
+
# This setting will be sent to the storage adapter's .new_storage method when
|
88
|
+
# initializing the storage. The base adapter (and the Hash adapter) ignore the
|
89
|
+
# options argument, but for the Redis and Sequel adapters, this is a handy way
|
90
|
+
# to pass through any options that Ruote's drivers understand.
|
91
|
+
#
|
92
|
+
# @Example:
|
93
|
+
# Bumbleworks.storage_options = { 'sequel_table_name' => 'bunnies_table' }
|
94
|
+
#
|
95
|
+
define_setting :storage_options
|
96
|
+
|
87
97
|
# Bumbleworks will attempt to log a variety of events (tasks becoming
|
88
98
|
# available, being claimed/released/completed, etc), and to do so it uses
|
89
99
|
# the logger registered in configuration. If no logger has been registered,
|
@@ -137,6 +147,7 @@ module Bumbleworks
|
|
137
147
|
|
138
148
|
def initialize
|
139
149
|
@storage_adapters = []
|
150
|
+
@storage_options = {}
|
140
151
|
@timeout ||= 5
|
141
152
|
end
|
142
153
|
|
data/lib/bumbleworks/ruote.rb
CHANGED
@@ -129,7 +129,7 @@ module Bumbleworks
|
|
129
129
|
end
|
130
130
|
|
131
131
|
def storage
|
132
|
-
@storage ||= Bumbleworks.storage_adapter.new_storage(Bumbleworks.storage)
|
132
|
+
@storage ||= Bumbleworks.storage_adapter.new_storage(Bumbleworks.storage, Bumbleworks.storage_options)
|
133
133
|
end
|
134
134
|
|
135
135
|
def reset!
|
@@ -12,12 +12,13 @@ module Bumbleworks
|
|
12
12
|
raise "Subclass responsibility"
|
13
13
|
end
|
14
14
|
|
15
|
-
def new_storage(storage)
|
15
|
+
def new_storage(storage, options = {})
|
16
16
|
raise UnsupportedStorage unless use?(storage)
|
17
|
-
wrap_storage_with_driver(storage)
|
17
|
+
wrap_storage_with_driver(storage, options)
|
18
18
|
end
|
19
19
|
|
20
|
-
def wrap_storage_with_driver(storage)
|
20
|
+
def wrap_storage_with_driver(storage, options = {})
|
21
|
+
# the base method ignores options; use them in subclasses
|
21
22
|
driver.new(storage)
|
22
23
|
end
|
23
24
|
|
data/lib/bumbleworks/version.rb
CHANGED
@@ -212,6 +212,17 @@ describe Bumbleworks::Configuration do
|
|
212
212
|
end
|
213
213
|
end
|
214
214
|
|
215
|
+
describe '#storage_options' do
|
216
|
+
it 'defaults to empty hash' do
|
217
|
+
subject.storage_options.should == {}
|
218
|
+
end
|
219
|
+
|
220
|
+
it 'can be overridden' do
|
221
|
+
subject.storage_options = { :smooshie => 'wubbles' }
|
222
|
+
subject.storage_options.should == { :smooshie => 'wubbles' }
|
223
|
+
end
|
224
|
+
end
|
225
|
+
|
215
226
|
describe "#storage_adapter" do
|
216
227
|
it 'defaults to first adapter in registered list that uses storage' do
|
217
228
|
right_adapter = double('right', :use? => true)
|
@@ -339,9 +339,11 @@ describe Bumbleworks::Ruote do
|
|
339
339
|
driven_storage = ::Ruote::HashStorage.new({})
|
340
340
|
storage = {}
|
341
341
|
adapter = double('Adapter')
|
342
|
-
|
342
|
+
options = { :thing => 'yay' }
|
343
|
+
adapter.stub(:new_storage).with(storage, options).and_return(driven_storage)
|
343
344
|
Bumbleworks.storage = storage
|
344
345
|
Bumbleworks.storage_adapter = adapter
|
346
|
+
Bumbleworks.storage_options = options
|
345
347
|
described_class.storage.should == driven_storage
|
346
348
|
end
|
347
349
|
end
|
@@ -59,25 +59,25 @@ describe Bumbleworks::StorageAdapter do
|
|
59
59
|
described_class.stub(:driver => storage_driver)
|
60
60
|
end
|
61
61
|
|
62
|
-
it 'returns driven storage' do
|
63
|
-
described_class.wrap_storage_with_driver(:awesome_stuff).should == :new_storage
|
62
|
+
it 'ignores options, and returns driven storage' do
|
63
|
+
described_class.wrap_storage_with_driver(:awesome_stuff, { :a => :b }).should == :new_storage
|
64
64
|
end
|
65
65
|
end
|
66
66
|
|
67
67
|
describe '.new_storage' do
|
68
68
|
before :each do
|
69
|
-
described_class.stub(:wrap_storage_with_driver).with(:awesome_stuff).and_return(:new_storage)
|
69
|
+
described_class.stub(:wrap_storage_with_driver).with(:awesome_stuff, { :a => :b }).and_return(:new_storage)
|
70
70
|
end
|
71
71
|
|
72
72
|
it 'returns driven storage if driver can use storage' do
|
73
73
|
described_class.stub(:use?).with(:awesome_stuff).and_return(true)
|
74
|
-
described_class.new_storage(:awesome_stuff).should == :new_storage
|
74
|
+
described_class.new_storage(:awesome_stuff, { :a => :b }).should == :new_storage
|
75
75
|
end
|
76
76
|
|
77
77
|
it "raises UnsupportedStorage if driver can't use storage" do
|
78
78
|
described_class.stub(:use?).with(:awesome_stuff).and_return(false)
|
79
79
|
expect {
|
80
|
-
described_class.new_storage(:awesome_stuff)
|
80
|
+
described_class.new_storage(:awesome_stuff, { :a => :b })
|
81
81
|
}.to raise_error(Bumbleworks::StorageAdapter::UnsupportedStorage)
|
82
82
|
end
|
83
83
|
end
|