delayed_paperclip 2.4.4.0 → 2.4.5.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -7,7 +7,7 @@ module DelayedPaperclip
7
7
  base.alias_method_chain :post_processing, :delay
8
8
  base.alias_method_chain :post_processing=, :delay
9
9
  base.alias_method_chain :save, :prepare_enqueueing
10
- base.alias_method_chain :url, :processed
10
+ base.alias_method_chain :most_appropriate_url, :processed
11
11
  base.alias_method_chain :post_process_styles, :processing
12
12
  end
13
13
 
@@ -21,9 +21,13 @@ module DelayedPaperclip
21
21
  @post_processing_with_delay = value
22
22
  end
23
23
 
24
+ def delayed_options
25
+ @instance.class.attachment_definitions[@name][:delayed]
26
+ end
27
+
24
28
  def delay_processing?
25
29
  if @post_processing_with_delay.nil?
26
- !!@instance.class.attachment_definitions[@name][:delayed]
30
+ !!delayed_options
27
31
  else
28
32
  !@post_processing_with_delay
29
33
  end
@@ -53,25 +57,18 @@ module DelayedPaperclip
53
57
  end
54
58
  end
55
59
 
56
- def url_with_processed style = default_style, include_updated_timestamp = @options.use_timestamp
57
- return url_without_processed style, include_updated_timestamp if !@instance.class.attachment_definitions[@name][:delayed].try(:[], :url_with_processing) || job_is_processing
58
-
59
- if !@instance.respond_to?(:"#{name}_processing?")
60
- url_without_processed style, include_updated_timestamp
60
+ def most_appropriate_url_with_processed
61
+ if original_filename.nil? || delayed_default_url?
62
+ default_url
61
63
  else
62
- if !processing?
63
- url_without_processed style, include_updated_timestamp
64
- else
65
- if dirty?
66
- url_without_processed style, include_updated_timestamp
67
- else
68
- default_url = @options.default_url.is_a?(Proc) ? @options.default_url.call(self) : @options.default_url
69
- interpolate(default_url, style)
70
- end
71
- end
64
+ @options.url
72
65
  end
73
66
  end
74
67
 
68
+ def delayed_default_url?
69
+ !(job_is_processing || dirty? || !delayed_options.try(:[], :url_with_processing) || !(@instance.respond_to?(:"#{name}_processing?") && processing?))
70
+ end
71
+
75
72
  end
76
73
  end
77
74
  end
@@ -73,7 +73,7 @@ module BaseDelayedPaperclipTest
73
73
  def test_unprocessed_image_returns_missing_url
74
74
  dummy = Dummy.new(:image => File.open("#{RAILS_ROOT}/test/fixtures/12k.png"))
75
75
  dummy.save!
76
- assert_equal "/images/original/missing.png", dummy.image.url
76
+ assert_equal "/images/original/missing.png", dummy.image.url(:original, :timestamp => false)
77
77
  process_jobs
78
78
  dummy.reload
79
79
  assert_match /\/system\/images\/1\/original\/12k.png/, dummy.image.url
@@ -112,7 +112,7 @@ module BaseDelayedPaperclipTest
112
112
  dummy.save!
113
113
  dummy.image = File.open("#{RAILS_ROOT}/test/fixtures/12k.png")
114
114
  dummy.save!
115
- assert_equal '/images/original/missing.png', dummy.image.url
115
+ assert_equal '/images/original/missing.png', dummy.image.url(:original, :timestamp => false)
116
116
  process_jobs
117
117
  assert_match(/system\/images\/.*original.*/, dummy.reload.image.url)
118
118
  end
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: 2.4.4.0
4
+ version: 2.4.5.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -14,18 +14,18 @@ date: 2011-11-12 00:00:00.000000000Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: paperclip
17
- requirement: &2152842880 !ruby/object:Gem::Requirement
17
+ requirement: &2165116360 !ruby/object:Gem::Requirement
18
18
  none: false
19
19
  requirements:
20
20
  - - ! '>='
21
21
  - !ruby/object:Gem::Version
22
- version: 2.4.4
22
+ version: 2.4.5
23
23
  type: :runtime
24
24
  prerelease: false
25
- version_requirements: *2152842880
25
+ version_requirements: *2165116360
26
26
  - !ruby/object:Gem::Dependency
27
27
  name: mocha
28
- requirement: &2152842460 !ruby/object:Gem::Requirement
28
+ requirement: &2165115920 !ruby/object:Gem::Requirement
29
29
  none: false
30
30
  requirements:
31
31
  - - ! '>='
@@ -33,10 +33,10 @@ dependencies:
33
33
  version: '0'
34
34
  type: :development
35
35
  prerelease: false
36
- version_requirements: *2152842460
36
+ version_requirements: *2165115920
37
37
  - !ruby/object:Gem::Dependency
38
38
  name: sqlite3
39
- requirement: &2152841940 !ruby/object:Gem::Requirement
39
+ requirement: &2165115400 !ruby/object:Gem::Requirement
40
40
  none: false
41
41
  requirements:
42
42
  - - ! '>='
@@ -44,10 +44,10 @@ dependencies:
44
44
  version: '0'
45
45
  type: :development
46
46
  prerelease: false
47
- version_requirements: *2152841940
47
+ version_requirements: *2165115400
48
48
  - !ruby/object:Gem::Dependency
49
49
  name: delayed_job
50
- requirement: &2152841460 !ruby/object:Gem::Requirement
50
+ requirement: &2165114820 !ruby/object:Gem::Requirement
51
51
  none: false
52
52
  requirements:
53
53
  - - ! '>='
@@ -55,10 +55,10 @@ dependencies:
55
55
  version: '0'
56
56
  type: :development
57
57
  prerelease: false
58
- version_requirements: *2152841460
58
+ version_requirements: *2165114820
59
59
  - !ruby/object:Gem::Dependency
60
60
  name: resque
61
- requirement: &2152840980 !ruby/object:Gem::Requirement
61
+ requirement: &2165114300 !ruby/object:Gem::Requirement
62
62
  none: false
63
63
  requirements:
64
64
  - - ! '>='
@@ -66,7 +66,7 @@ dependencies:
66
66
  version: '0'
67
67
  type: :development
68
68
  prerelease: false
69
- version_requirements: *2152840980
69
+ version_requirements: *2165114300
70
70
  description: Process your Paperclip attachments in the background with delayed_job,
71
71
  Resque or your own processor.
72
72
  email: jesse@jstorimer.com