delayed_paperclip 2.10.0 → 3.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +4 -4
- data/Appraisals +1 -13
- data/README.md +41 -95
- data/delayed_paperclip.gemspec +7 -8
- data/gemfiles/5.0.gemfile +1 -1
- data/lib/delayed_paperclip.rb +3 -13
- data/lib/delayed_paperclip/process_job.rb +14 -0
- data/lib/delayed_paperclip/railtie.rb +10 -15
- data/lib/delayed_paperclip/version.rb +1 -1
- data/spec/delayed_paperclip/attachment_spec.rb +0 -1
- data/spec/delayed_paperclip/class_methods_spec.rb +0 -1
- data/spec/delayed_paperclip/instance_methods_spec.rb +0 -1
- data/spec/delayed_paperclip/url_generator_spec.rb +0 -1
- data/spec/delayed_paperclip_spec.rb +15 -22
- data/spec/integration/base_delayed_paperclip_spec.rb +0 -5
- data/spec/integration/examples/base.rb +6 -4
- data/spec/integration/process_job_spec.rb +26 -0
- data/spec/spec_helper.rb +7 -11
- metadata +22 -84
- data/gemfiles/3.2.gemfile +0 -7
- data/gemfiles/4.0.gemfile +0 -7
- data/gemfiles/4.1.gemfile +0 -7
- data/init.rb +0 -4
- data/lib/delayed_paperclip/jobs.rb +0 -8
- data/lib/delayed_paperclip/jobs/active_job.rb +0 -14
- data/lib/delayed_paperclip/jobs/delayed_job.rb +0 -46
- data/lib/delayed_paperclip/jobs/resque.rb +0 -22
- data/lib/delayed_paperclip/jobs/sidekiq.rb +0 -30
- data/rails/init.rb +0 -2
- data/spec/integration/active_job_inline_spec.rb +0 -26
- data/spec/integration/active_job_resque_spec.rb +0 -28
- data/spec/integration/active_job_sidekiq_spec.rb +0 -34
- data/spec/integration/delayed_job_spec.rb +0 -63
- data/spec/integration/resque_spec.rb +0 -47
- data/spec/integration/sidekiq_spec.rb +0 -54
@@ -0,0 +1,14 @@
|
|
1
|
+
require "active_job"
|
2
|
+
|
3
|
+
module DelayedPaperclip
|
4
|
+
class ProcessJob < ActiveJob::Base
|
5
|
+
def self.enqueue_delayed_paperclip(instance_klass, instance_id, attachment_name)
|
6
|
+
queue_name = instance_klass.constantize.paperclip_definitions[attachment_name][:delayed][:queue]
|
7
|
+
set(:queue => queue_name).perform_later(instance_klass, instance_id, attachment_name.to_s)
|
8
|
+
end
|
9
|
+
|
10
|
+
def perform(instance_klass, instance_id, attachment_name)
|
11
|
+
DelayedPaperclip.process_job(instance_klass, instance_id, attachment_name.to_sym)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -1,26 +1,21 @@
|
|
1
|
-
require
|
2
|
-
require
|
1
|
+
require "paperclip"
|
2
|
+
require "delayed_paperclip"
|
3
3
|
|
4
4
|
module DelayedPaperclip
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
ActiveSupport.on_load :active_record do
|
12
|
-
DelayedPaperclip::Railtie.insert
|
13
|
-
end
|
5
|
+
# On initialzation, include DelayedPaperclip
|
6
|
+
class Railtie < Rails::Railtie
|
7
|
+
initializer "delayed_paperclip.insert_into_active_record" do |app|
|
8
|
+
ActiveSupport.on_load :active_record do
|
9
|
+
DelayedPaperclip::Railtie.insert
|
10
|
+
end
|
14
11
|
|
15
|
-
|
16
|
-
|
17
|
-
end
|
12
|
+
if app.config.respond_to?(:delayed_paperclip_defaults)
|
13
|
+
DelayedPaperclip.options.merge!(app.config.delayed_paperclip_defaults)
|
18
14
|
end
|
19
15
|
end
|
20
16
|
end
|
21
17
|
|
22
18
|
class Railtie
|
23
|
-
|
24
19
|
# Glue includes DelayedPaperclip Class Methods and Instance Methods into ActiveRecord
|
25
20
|
# Attachment and URL Generator extends Paperclip
|
26
21
|
def self.insert
|
@@ -1,36 +1,29 @@
|
|
1
1
|
require 'spec_helper'
|
2
|
-
require 'resque'
|
3
2
|
|
4
3
|
describe DelayedPaperclip do
|
5
4
|
before :each do
|
6
5
|
reset_dummy
|
7
6
|
end
|
8
7
|
|
9
|
-
|
10
|
-
|
11
|
-
DelayedPaperclip.options
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
it ".options returns basic options" do
|
16
|
-
DelayedPaperclip.options.should == {:background_job_class => DelayedPaperclip::Jobs::Resque,
|
17
|
-
:url_with_processing => true,
|
18
|
-
:processing_image_url => nil,
|
19
|
-
:queue => "paperclip"}
|
20
|
-
end
|
8
|
+
describe ".options" do
|
9
|
+
it ".options returns basic options" do
|
10
|
+
DelayedPaperclip.options.should == {:background_job_class => DelayedPaperclip::ProcessJob,
|
11
|
+
:url_with_processing => true,
|
12
|
+
:processing_image_url => nil,
|
13
|
+
:queue => "paperclip"}
|
21
14
|
end
|
15
|
+
end
|
22
16
|
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
end
|
17
|
+
describe ".processor" do
|
18
|
+
it ".processor returns processor" do
|
19
|
+
DelayedPaperclip.processor.should == DelayedPaperclip::ProcessJob
|
27
20
|
end
|
21
|
+
end
|
28
22
|
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
end
|
23
|
+
describe ".enqueue" do
|
24
|
+
it "delegates to processor" do
|
25
|
+
DelayedPaperclip::ProcessJob.expects(:enqueue_delayed_paperclip).with("Dummy", 1, :image)
|
26
|
+
DelayedPaperclip.enqueue("Dummy", 1, :image)
|
34
27
|
end
|
35
28
|
end
|
36
29
|
|
@@ -1,11 +1,6 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe "Base Delayed Paperclip Integration" do
|
4
|
-
before :each do
|
5
|
-
DelayedPaperclip.options[:background_job_class] = DelayedPaperclip::Jobs::Resque
|
6
|
-
Resque.remove_queue(:paperclip)
|
7
|
-
end
|
8
|
-
|
9
4
|
let(:dummy) { Dummy.create }
|
10
5
|
|
11
6
|
before :each do
|
@@ -104,14 +104,16 @@ shared_examples "base usage" do
|
|
104
104
|
end
|
105
105
|
|
106
106
|
context "with error" do
|
107
|
-
|
107
|
+
it "stays true even if errored" do
|
108
108
|
Paperclip::Attachment.any_instance.stubs(:reprocess!).raises(StandardError.new('oops'))
|
109
|
-
end
|
110
109
|
|
111
|
-
it "stays true even if errored" do
|
112
110
|
dummy.save!
|
113
111
|
dummy.image_processing?.should be_truthy
|
114
|
-
|
112
|
+
|
113
|
+
expect do
|
114
|
+
process_jobs
|
115
|
+
end.to raise_error(StandardError)
|
116
|
+
|
115
117
|
dummy.image_processing?.should be_truthy
|
116
118
|
dummy.reload.image_processing?.should be_truthy
|
117
119
|
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
RSpec.describe "DelayedJob::ProcessJob" do
|
4
|
+
before :each do
|
5
|
+
ActiveJob::Base.queue_adapter = :test
|
6
|
+
ActiveJob::Base.logger = nil
|
7
|
+
end
|
8
|
+
|
9
|
+
let(:dummy) { Dummy.new(:image => File.open("#{ROOT}/fixtures/12k.png")) }
|
10
|
+
|
11
|
+
describe "integration tests" do
|
12
|
+
include_examples "base usage"
|
13
|
+
end
|
14
|
+
|
15
|
+
def process_jobs
|
16
|
+
ActiveJob::Base.queue_adapter.enqueued_jobs.each do |job|
|
17
|
+
job[:job].send(:perform_now, *job[:args])
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
def jobs_count(queue = "paperclip")
|
22
|
+
ActiveJob::Base.queue_adapter.enqueued_jobs.count do |job|
|
23
|
+
job[:queue] == queue
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
data/spec/spec_helper.rb
CHANGED
@@ -1,14 +1,10 @@
|
|
1
1
|
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
2
2
|
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), "..", "lib"))
|
3
3
|
|
4
|
+
require 'rails'
|
4
5
|
require 'active_record'
|
5
6
|
require 'rspec'
|
6
|
-
require 'fakeredis/rspec'
|
7
7
|
require 'mocha/api'
|
8
|
-
begin
|
9
|
-
require 'active_job'
|
10
|
-
rescue LoadError
|
11
|
-
end
|
12
8
|
|
13
9
|
begin
|
14
10
|
require 'pry'
|
@@ -28,9 +24,6 @@ if ActiveRecord::Base.respond_to?(:raise_in_transactional_callbacks=) && Rails::
|
|
28
24
|
ActiveRecord::Base.raise_in_transactional_callbacks = true
|
29
25
|
end
|
30
26
|
|
31
|
-
require "active_support/deprecation"
|
32
|
-
ActiveSupport::Deprecation.silenced = true
|
33
|
-
|
34
27
|
# Connect to sqlite
|
35
28
|
ActiveRecord::Base.establish_connection(
|
36
29
|
"adapter" => "sqlite3",
|
@@ -39,8 +32,11 @@ ActiveRecord::Base.establish_connection(
|
|
39
32
|
|
40
33
|
# Path for filesystem writing
|
41
34
|
ROOT = Pathname.new(File.expand_path("../.", __FILE__))
|
42
|
-
|
43
|
-
|
35
|
+
|
36
|
+
logger = Logger.new(ROOT.join("tmp/debug.log"))
|
37
|
+
ActiveRecord::Base.logger = logger
|
38
|
+
ActiveJob::Base.logger = logger
|
39
|
+
Paperclip.logger = logger
|
44
40
|
|
45
41
|
RSpec.configure do |config|
|
46
42
|
config.mock_with :mocha
|
@@ -57,7 +53,7 @@ end
|
|
57
53
|
|
58
54
|
def reset_global_default_options
|
59
55
|
DelayedPaperclip.options.merge!({
|
60
|
-
:background_job_class => DelayedPaperclip::
|
56
|
+
:background_job_class => DelayedPaperclip::ProcessJob,
|
61
57
|
:url_with_processing => true,
|
62
58
|
:processing_image_url => nil
|
63
59
|
})
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: delayed_paperclip
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 3.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jesse Storimer
|
@@ -11,7 +11,7 @@ authors:
|
|
11
11
|
autorequire:
|
12
12
|
bindir: bin
|
13
13
|
cert_chain: []
|
14
|
-
date: 2016-
|
14
|
+
date: 2016-08-01 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: paperclip
|
@@ -28,49 +28,21 @@ dependencies:
|
|
28
28
|
- !ruby/object:Gem::Version
|
29
29
|
version: '3.3'
|
30
30
|
- !ruby/object:Gem::Dependency
|
31
|
-
name:
|
32
|
-
requirement: !ruby/object:Gem::Requirement
|
33
|
-
requirements:
|
34
|
-
- - ">="
|
35
|
-
- !ruby/object:Gem::Version
|
36
|
-
version: '0'
|
37
|
-
type: :development
|
38
|
-
prerelease: false
|
39
|
-
version_requirements: !ruby/object:Gem::Requirement
|
40
|
-
requirements:
|
41
|
-
- - ">="
|
42
|
-
- !ruby/object:Gem::Version
|
43
|
-
version: '0'
|
44
|
-
- !ruby/object:Gem::Dependency
|
45
|
-
name: rspec
|
46
|
-
requirement: !ruby/object:Gem::Requirement
|
47
|
-
requirements:
|
48
|
-
- - "<"
|
49
|
-
- !ruby/object:Gem::Version
|
50
|
-
version: '3.0'
|
51
|
-
type: :development
|
52
|
-
prerelease: false
|
53
|
-
version_requirements: !ruby/object:Gem::Requirement
|
54
|
-
requirements:
|
55
|
-
- - "<"
|
56
|
-
- !ruby/object:Gem::Version
|
57
|
-
version: '3.0'
|
58
|
-
- !ruby/object:Gem::Dependency
|
59
|
-
name: sqlite3
|
31
|
+
name: activejob
|
60
32
|
requirement: !ruby/object:Gem::Requirement
|
61
33
|
requirements:
|
62
34
|
- - ">="
|
63
35
|
- !ruby/object:Gem::Version
|
64
|
-
version: '
|
65
|
-
type: :
|
36
|
+
version: '4.2'
|
37
|
+
type: :runtime
|
66
38
|
prerelease: false
|
67
39
|
version_requirements: !ruby/object:Gem::Requirement
|
68
40
|
requirements:
|
69
41
|
- - ">="
|
70
42
|
- !ruby/object:Gem::Version
|
71
|
-
version: '
|
43
|
+
version: '4.2'
|
72
44
|
- !ruby/object:Gem::Dependency
|
73
|
-
name:
|
45
|
+
name: mocha
|
74
46
|
requirement: !ruby/object:Gem::Requirement
|
75
47
|
requirements:
|
76
48
|
- - ">="
|
@@ -84,21 +56,21 @@ dependencies:
|
|
84
56
|
- !ruby/object:Gem::Version
|
85
57
|
version: '0'
|
86
58
|
- !ruby/object:Gem::Dependency
|
87
|
-
name:
|
59
|
+
name: rspec
|
88
60
|
requirement: !ruby/object:Gem::Requirement
|
89
61
|
requirements:
|
90
|
-
- - "
|
62
|
+
- - "<"
|
91
63
|
- !ruby/object:Gem::Version
|
92
|
-
version: '0'
|
64
|
+
version: '3.0'
|
93
65
|
type: :development
|
94
66
|
prerelease: false
|
95
67
|
version_requirements: !ruby/object:Gem::Requirement
|
96
68
|
requirements:
|
97
|
-
- - "
|
69
|
+
- - "<"
|
98
70
|
- !ruby/object:Gem::Version
|
99
|
-
version: '0'
|
71
|
+
version: '3.0'
|
100
72
|
- !ruby/object:Gem::Dependency
|
101
|
-
name:
|
73
|
+
name: sqlite3
|
102
74
|
requirement: !ruby/object:Gem::Requirement
|
103
75
|
requirements:
|
104
76
|
- - ">="
|
@@ -111,20 +83,6 @@ dependencies:
|
|
111
83
|
- - ">="
|
112
84
|
- !ruby/object:Gem::Version
|
113
85
|
version: '0'
|
114
|
-
- !ruby/object:Gem::Dependency
|
115
|
-
name: sidekiq
|
116
|
-
requirement: !ruby/object:Gem::Requirement
|
117
|
-
requirements:
|
118
|
-
- - ">="
|
119
|
-
- !ruby/object:Gem::Version
|
120
|
-
version: '4.0'
|
121
|
-
type: :development
|
122
|
-
prerelease: false
|
123
|
-
version_requirements: !ruby/object:Gem::Requirement
|
124
|
-
requirements:
|
125
|
-
- - ">="
|
126
|
-
- !ruby/object:Gem::Version
|
127
|
-
version: '4.0'
|
128
86
|
- !ruby/object:Gem::Dependency
|
129
87
|
name: appraisal
|
130
88
|
requirement: !ruby/object:Gem::Requirement
|
@@ -168,7 +126,7 @@ dependencies:
|
|
168
126
|
- !ruby/object:Gem::Version
|
169
127
|
version: '0'
|
170
128
|
- !ruby/object:Gem::Dependency
|
171
|
-
name:
|
129
|
+
name: activerecord
|
172
130
|
requirement: !ruby/object:Gem::Requirement
|
173
131
|
requirements:
|
174
132
|
- - ">="
|
@@ -182,7 +140,7 @@ dependencies:
|
|
182
140
|
- !ruby/object:Gem::Version
|
183
141
|
version: '0'
|
184
142
|
- !ruby/object:Gem::Dependency
|
185
|
-
name:
|
143
|
+
name: railties
|
186
144
|
requirement: !ruby/object:Gem::Requirement
|
187
145
|
requirements:
|
188
146
|
- - ">="
|
@@ -195,8 +153,7 @@ dependencies:
|
|
195
153
|
- - ">="
|
196
154
|
- !ruby/object:Gem::Version
|
197
155
|
version: '0'
|
198
|
-
description: Process your Paperclip attachments in the background with
|
199
|
-
Resque, Sidekiq or your own processor.
|
156
|
+
description: Process your Paperclip attachments in the background with ActiveJob
|
200
157
|
email:
|
201
158
|
- james@jamesrgifford.com
|
202
159
|
- scott@artsicle.com
|
@@ -214,23 +171,14 @@ files:
|
|
214
171
|
- README.md
|
215
172
|
- Rakefile
|
216
173
|
- delayed_paperclip.gemspec
|
217
|
-
- gemfiles/3.2.gemfile
|
218
|
-
- gemfiles/4.0.gemfile
|
219
|
-
- gemfiles/4.1.gemfile
|
220
174
|
- gemfiles/4.2.gemfile
|
221
175
|
- gemfiles/5.0.gemfile
|
222
|
-
- init.rb
|
223
176
|
- lib/delayed_paperclip.rb
|
224
177
|
- lib/delayed_paperclip/attachment.rb
|
225
|
-
- lib/delayed_paperclip/
|
226
|
-
- lib/delayed_paperclip/jobs/active_job.rb
|
227
|
-
- lib/delayed_paperclip/jobs/delayed_job.rb
|
228
|
-
- lib/delayed_paperclip/jobs/resque.rb
|
229
|
-
- lib/delayed_paperclip/jobs/sidekiq.rb
|
178
|
+
- lib/delayed_paperclip/process_job.rb
|
230
179
|
- lib/delayed_paperclip/railtie.rb
|
231
180
|
- lib/delayed_paperclip/url_generator.rb
|
232
181
|
- lib/delayed_paperclip/version.rb
|
233
|
-
- rails/init.rb
|
234
182
|
- spec/delayed_paperclip/attachment_spec.rb
|
235
183
|
- spec/delayed_paperclip/class_methods_spec.rb
|
236
184
|
- spec/delayed_paperclip/instance_methods_spec.rb
|
@@ -238,17 +186,12 @@ files:
|
|
238
186
|
- spec/delayed_paperclip_spec.rb
|
239
187
|
- spec/fixtures/12k.png
|
240
188
|
- spec/fixtures/missing.png
|
241
|
-
- spec/integration/active_job_inline_spec.rb
|
242
|
-
- spec/integration/active_job_resque_spec.rb
|
243
|
-
- spec/integration/active_job_sidekiq_spec.rb
|
244
189
|
- spec/integration/base_delayed_paperclip_spec.rb
|
245
|
-
- spec/integration/delayed_job_spec.rb
|
246
190
|
- spec/integration/examples/base.rb
|
247
|
-
- spec/integration/
|
248
|
-
- spec/integration/sidekiq_spec.rb
|
191
|
+
- spec/integration/process_job_spec.rb
|
249
192
|
- spec/spec_helper.rb
|
250
193
|
- spec/tmp/.keep
|
251
|
-
homepage:
|
194
|
+
homepage: https://github.com/jrgifford/delayed_paperclip
|
252
195
|
licenses: []
|
253
196
|
metadata: {}
|
254
197
|
post_install_message:
|
@@ -259,7 +202,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
259
202
|
requirements:
|
260
203
|
- - ">="
|
261
204
|
- !ruby/object:Gem::Version
|
262
|
-
version:
|
205
|
+
version: 2.0.0
|
263
206
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
264
207
|
requirements:
|
265
208
|
- - ">="
|
@@ -270,7 +213,7 @@ rubyforge_project:
|
|
270
213
|
rubygems_version: 2.4.5
|
271
214
|
signing_key:
|
272
215
|
specification_version: 4
|
273
|
-
summary: Process your Paperclip attachments in the background
|
216
|
+
summary: Process your Paperclip attachments in the background
|
274
217
|
test_files:
|
275
218
|
- spec/delayed_paperclip/attachment_spec.rb
|
276
219
|
- spec/delayed_paperclip/class_methods_spec.rb
|
@@ -279,13 +222,8 @@ test_files:
|
|
279
222
|
- spec/delayed_paperclip_spec.rb
|
280
223
|
- spec/fixtures/12k.png
|
281
224
|
- spec/fixtures/missing.png
|
282
|
-
- spec/integration/active_job_inline_spec.rb
|
283
|
-
- spec/integration/active_job_resque_spec.rb
|
284
|
-
- spec/integration/active_job_sidekiq_spec.rb
|
285
225
|
- spec/integration/base_delayed_paperclip_spec.rb
|
286
|
-
- spec/integration/delayed_job_spec.rb
|
287
226
|
- spec/integration/examples/base.rb
|
288
|
-
- spec/integration/
|
289
|
-
- spec/integration/sidekiq_spec.rb
|
227
|
+
- spec/integration/process_job_spec.rb
|
290
228
|
- spec/spec_helper.rb
|
291
229
|
- spec/tmp/.keep
|