Skip to content
This repository was archived by the owner on Oct 5, 2018. It is now read-only.

Commit 458e101

Browse files
author
Scott Carleton
committed
Merge pull request #178 from jrgifford/deprecate-adapters
Deprecate Resque, Sidekiq and DelayedJob adapters.
2 parents 8d071a3 + c2b9aa1 commit 458e101

File tree

8 files changed

+59
-0
lines changed

8 files changed

+59
-0
lines changed

README.md

+6
Original file line numberDiff line numberDiff line change
@@ -83,17 +83,23 @@ end
8383

8484
### Resque
8585

86+
Resque adapter is deprecated. Please use ActiveJob one.
87+
8688
Make sure that you have [Resque](https://github.com/resque/resque) up and running. The jobs will be
8789
dispatched to the <code>:paperclip</code> queue, so you can correctly
8890
dispatch your worker. Configure resque and your workers exactly as you
8991
would otherwise.
9092

9193
### DJ
9294

95+
DelayedJob adapter is deprecated. Please use ActiveJob one.
96+
9397
Just make sure that you have DJ up and running.
9498

9599
### Sidekiq
96100

101+
Sidekiq adapter is deprecated. Please use ActiveJob one.
102+
97103
Make sure that [Sidekiq](http://github.com/mperham/sidekiq) is running and listening to the
98104
`paperclip` queue, either by adding it to your
99105
`sidekiq.yml` config file under `- queues:` or by

lib/delayed_paperclip/jobs/delayed_job.rb

+11
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
require 'delayed_job'
2+
require 'active_support/deprecation'
23

34
module DelayedPaperclip
45
module Jobs
@@ -8,6 +9,11 @@ class DelayedJob < Struct.new(:instance_klass, :instance_id, :attachment_name)
89
if Gem.loaded_specs['delayed_job'].version >= Gem::Version.new("2.1.0")
910

1011
def self.enqueue_delayed_paperclip(instance_klass, instance_id, attachment_name)
12+
ActiveSupport::Deprecation.warn(<<-MESSAGE)
13+
Using DelayedJob adapter for delayed_paperclip is deprecated and will be removed in version 3.0.0.
14+
Please use ActiveJob adapter.
15+
MESSAGE
16+
1117
::Delayed::Job.enqueue(
1218
:payload_object => new(instance_klass, instance_id, attachment_name),
1319
:priority => instance_klass.constantize.paperclip_definitions[attachment_name][:delayed][:priority].to_i,
@@ -18,6 +24,11 @@ def self.enqueue_delayed_paperclip(instance_klass, instance_id, attachment_name)
1824
else
1925

2026
def self.enqueue_delayed_paperclip(instance_klass, instance_id, attachment_name)
27+
ActiveSupport::Deprecation.warn(<<-MESSAGE)
28+
Using DelayedJob adapter for delayed_paperclip is deprecated and will be removed in version 3.0.0.
29+
Please use ActiveJob adapter.
30+
MESSAGE
31+
2132
::Delayed::Job.enqueue(
2233
new(instance_klass, instance_id, attachment_name),
2334
instance_klass.constantize.paperclip_definitions[attachment_name][:delayed][:priority].to_i,

lib/delayed_paperclip/jobs/resque.rb

+6
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,17 @@
11
require 'resque'
2+
require 'active_support/deprecation'
23

34
module DelayedPaperclip
45
module Jobs
56
class Resque
67
def self.enqueue_delayed_paperclip(instance_klass, instance_id, attachment_name)
78
@queue = instance_klass.constantize.paperclip_definitions[attachment_name][:delayed][:queue]
89
::Resque.enqueue(self, instance_klass, instance_id, attachment_name)
10+
11+
ActiveSupport::Deprecation.warn(<<-MESSAGE)
12+
Using Resque adapter for delayed_paperclip is deprecated and will be removed in version 3.0.0.
13+
Please use ActiveJob adapter.
14+
MESSAGE
915
end
1016

1117
def self.perform(instance_klass, instance_id, attachment_name)

lib/delayed_paperclip/jobs/sidekiq.rb

+6
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,17 @@
11
require 'sidekiq/worker'
2+
require 'active_support/deprecation'
23

34
module DelayedPaperclip
45
module Jobs
56
class Sidekiq
67
include ::Sidekiq::Worker
78

89
def self.enqueue_delayed_paperclip(instance_klass, instance_id, attachment_name)
10+
ActiveSupport::Deprecation.warn(<<-MESSAGE)
11+
Using Sidekiq adapter for delayed_paperclip is deprecated and will be removed in version 3.0.0.
12+
Please use ActiveJob adapter.
13+
MESSAGE
14+
915
queue_name = instance_klass.constantize.paperclip_definitions[attachment_name][:delayed][:queue]
1016
# Sidekiq >= 4.1.0
1117
if respond_to?(:set)

spec/integration/delayed_job_spec.rb

+9
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,15 @@
2727
dummy.save!
2828
Delayed::Job.last.payload_object.perform
2929
end
30+
31+
it "is deprecated" do
32+
ActiveSupport::Deprecation.expects(:warn)
33+
34+
dummy.image = File.open("#{ROOT}/fixtures/12k.png")
35+
Paperclip::Attachment.any_instance.expects(:reprocess!)
36+
dummy.save!
37+
Delayed::Job.last.payload_object.perform
38+
end
3039
end
3140

3241
def process_jobs

spec/integration/resque_spec.rb

+9
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,15 @@
2525
dummy.save!
2626
DelayedPaperclip::Jobs::Resque.perform(dummy.class.name, dummy.id, :image)
2727
end
28+
29+
it "is deprecated" do
30+
ActiveSupport::Deprecation.expects(:warn)
31+
32+
dummy.image = File.open("#{ROOT}/fixtures/12k.png")
33+
Paperclip::Attachment.any_instance.expects(:reprocess!)
34+
dummy.save!
35+
DelayedPaperclip::Jobs::Resque.perform(dummy.class.name, dummy.id, :image)
36+
end
2837
end
2938

3039
def process_jobs

spec/integration/sidekiq_spec.rb

+9
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,15 @@
2626
dummy.save!
2727
DelayedPaperclip::Jobs::Sidekiq.new.perform(dummy.class.name, dummy.id, :image)
2828
end
29+
30+
it "is deprecated" do
31+
ActiveSupport::Deprecation.expects(:warn)
32+
33+
dummy.image = File.open("#{ROOT}/fixtures/12k.png")
34+
Paperclip::Attachment.any_instance.expects(:reprocess!)
35+
dummy.save!
36+
DelayedPaperclip::Jobs::Sidekiq.new.perform(dummy.class.name, dummy.id, :image)
37+
end
2938
end
3039

3140
def process_jobs

spec/spec_helper.rb

+3
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@
2828
ActiveRecord::Base.raise_in_transactional_callbacks = true
2929
end
3030

31+
require "active_support/deprecation"
32+
ActiveSupport::Deprecation.silenced = true
33+
3134
# Connect to sqlite
3235
ActiveRecord::Base.establish_connection(
3336
"adapter" => "sqlite3",

0 commit comments

Comments
 (0)