carrierwave_backgrounder 0.1.5 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.md +8 -0
- data/lib/backgrounder/support/backends.rb +1 -27
- data/lib/backgrounder/version.rb +1 -1
- data/lib/backgrounder/workers/process_asset.rb +0 -2
- data/lib/backgrounder/workers/store_asset.rb +0 -1
- data/lib/carrierwave_backgrounder.rb +10 -0
- data/spec/backgrounder/support/backends_spec.rb +0 -56
- metadata +3 -3
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,11 @@
|
|
1
|
+
## 0.2.0
|
2
|
+
|
3
|
+
### enhancements
|
4
|
+
* [Breaking Change] Require configure block to be set in an initializer removing autodetect backend.
|
5
|
+
|
6
|
+
### bug fixes
|
7
|
+
* [#108] Remove the need to set an order in the Gemfile when using sidekiq [matthewsmart].
|
8
|
+
|
1
9
|
## 0.1.5
|
2
10
|
|
3
11
|
### bug fixes
|
@@ -12,21 +12,7 @@ module Support
|
|
12
12
|
def backend(queue_name=nil, args={})
|
13
13
|
return @backend if @backend
|
14
14
|
@queue_options = args
|
15
|
-
@backend = queue_name
|
16
|
-
determine_backend
|
17
|
-
end
|
18
|
-
|
19
|
-
def available_backends
|
20
|
-
@available_backends ||= begin
|
21
|
-
backends = []
|
22
|
-
backends << :girl_friday if defined? ::GirlFriday
|
23
|
-
backends << :delayed_job if defined? ::Delayed::Job
|
24
|
-
backends << :resque if defined? ::Resque
|
25
|
-
backends << :qu if defined? ::Qu
|
26
|
-
backends << :sidekiq if defined? ::Sidekiq
|
27
|
-
backends << :qc if defined? ::QC
|
28
|
-
backends
|
29
|
-
end
|
15
|
+
@backend = queue_name
|
30
16
|
end
|
31
17
|
|
32
18
|
def enqueue_for_backend(worker, class_name, subject_id, mounted_as)
|
@@ -35,18 +21,6 @@ module Support
|
|
35
21
|
|
36
22
|
private
|
37
23
|
|
38
|
-
def determine_backend
|
39
|
-
@backend = if available_backends.empty?
|
40
|
-
warn 'WARNING: No available queue backends found for CarrierWave::Backgrounder. Using the :immediate.'
|
41
|
-
:immediate
|
42
|
-
elsif available_backends.size > 1
|
43
|
-
raise ::CarrierWave::Backgrounder::TooManyBackendsAvailableError,
|
44
|
-
"You have too many backends available: #{available_backends.inspect}. Please specify which one to use in configuration block"
|
45
|
-
else
|
46
|
-
available_backends.first
|
47
|
-
end
|
48
|
-
end
|
49
|
-
|
50
24
|
def enqueue_delayed_job(worker, *args)
|
51
25
|
::Delayed::Job.enqueue worker.new(*args), :queue => queue_options[:queue]
|
52
26
|
end
|
data/lib/backgrounder/version.rb
CHANGED
@@ -12,6 +12,16 @@ module CarrierWave
|
|
12
12
|
|
13
13
|
def self.configure
|
14
14
|
yield self
|
15
|
+
if @backend == :sidekiq
|
16
|
+
::CarrierWave::Workers::ProcessAsset.class_eval do
|
17
|
+
require 'sidekiq'
|
18
|
+
include ::Sidekiq::Worker
|
19
|
+
end
|
20
|
+
::CarrierWave::Workers::StoreAsset.class_eval do
|
21
|
+
require 'sidekiq'
|
22
|
+
include ::Sidekiq::Worker
|
23
|
+
end
|
24
|
+
end
|
15
25
|
end
|
16
26
|
|
17
27
|
end
|
@@ -9,32 +9,6 @@ describe Support::Backends do
|
|
9
9
|
mock_module.send :include, Support::Backends
|
10
10
|
end
|
11
11
|
|
12
|
-
describe 'enumerating available backends' do
|
13
|
-
it 'detects GirlFriday' do
|
14
|
-
expect(mock_module.available_backends).to include(:girl_friday)
|
15
|
-
end
|
16
|
-
|
17
|
-
it 'detects Delayed::Job' do
|
18
|
-
expect(mock_module.available_backends).to include(:delayed_job)
|
19
|
-
end
|
20
|
-
|
21
|
-
it 'detects Resque' do
|
22
|
-
expect(mock_module.available_backends).to include(:resque)
|
23
|
-
end
|
24
|
-
|
25
|
-
it 'detects Qu' do
|
26
|
-
expect(mock_module.available_backends).to include(:qu)
|
27
|
-
end
|
28
|
-
|
29
|
-
it 'detects Sidekiq' do
|
30
|
-
expect(mock_module.available_backends).to include(:sidekiq)
|
31
|
-
end
|
32
|
-
|
33
|
-
it 'detects QC' do
|
34
|
-
expect(mock_module.available_backends).to include(:qc)
|
35
|
-
end
|
36
|
-
end
|
37
|
-
|
38
12
|
describe 'setting backend' do
|
39
13
|
it 'using #backend=' do
|
40
14
|
mock_module.backend = :delayed_job
|
@@ -52,36 +26,6 @@ describe Support::Backends do
|
|
52
26
|
end
|
53
27
|
end
|
54
28
|
|
55
|
-
describe 'auto detect backends' do
|
56
|
-
before do
|
57
|
-
mock_module.instance_variable_set('@backend', nil)
|
58
|
-
end
|
59
|
-
|
60
|
-
it 'sets the backend to immediate if none available' do
|
61
|
-
suppress_warnings do
|
62
|
-
mock_module.stubs(:available_backends).returns([])
|
63
|
-
expect(mock_module.backend).to eql(:immediate)
|
64
|
-
end
|
65
|
-
end
|
66
|
-
|
67
|
-
it 'sets a backend automatically if only one is available' do
|
68
|
-
mock_module.stubs(:available_backends).returns([ :qu ])
|
69
|
-
expect(mock_module.backend).to eql(:qu)
|
70
|
-
end
|
71
|
-
|
72
|
-
it 'raises an error if more than one backend is available' do
|
73
|
-
mock_module.stubs(:available_backends).returns([:qu, :resque])
|
74
|
-
expect {
|
75
|
-
mock_module.backend
|
76
|
-
}.to raise_error(CarrierWave::Backgrounder::TooManyBackendsAvailableError)
|
77
|
-
end
|
78
|
-
|
79
|
-
it 'does not clobber a manually set backend' do
|
80
|
-
mock_module.backend = :not_a_backend
|
81
|
-
expect(mock_module.backend).to eql(:not_a_backend)
|
82
|
-
end
|
83
|
-
end
|
84
|
-
|
85
29
|
describe '#enqueue_for_backend' do
|
86
30
|
let!(:worker) { MockWorker.new('FakeClass', 1, :image) }
|
87
31
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: carrierwave_backgrounder
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -127,7 +127,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
127
127
|
version: '0'
|
128
128
|
segments:
|
129
129
|
- 0
|
130
|
-
hash:
|
130
|
+
hash: 517086272646554403
|
131
131
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
132
132
|
none: false
|
133
133
|
requirements:
|
@@ -136,7 +136,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
136
136
|
version: '0'
|
137
137
|
segments:
|
138
138
|
- 0
|
139
|
-
hash:
|
139
|
+
hash: 517086272646554403
|
140
140
|
requirements: []
|
141
141
|
rubyforge_project:
|
142
142
|
rubygems_version: 1.8.24
|