delayed_paperclip 2.4.5.1 → 2.4.5.2

Sign up to get free protection for your applications and to get access to all the features.
data/README.textile CHANGED
@@ -1,4 +1,4 @@
1
- h1. Delayed::Paperclip !https://secure.travis-ci.org/jstorimer/delayed_paperclip.png!
1
+ h1. Delayed::Paperclip !https://secure.travis-ci.org/jrgifford/delayed_paperclip.png!
2
2
 
3
3
  Delayed_paperclip lets you process your "Paperclip":http://github.com/thoughtbot/paperclip attachments in a background task with "delayed_job":http://github.com/tobi/delayed_job or "Resque":http://github.com/defunkt/resque.
4
4
 
@@ -76,7 +76,7 @@ To have the missing image url be outputted by paperclip while the image is being
76
76
  @user = User.new(:avatar => File.new(...))
77
77
  @user.save
78
78
  @user.avatar.url #=> "/images/original/missing.png"
79
- Delayed::Job.work_off
79
+ Delayed::Worker.new.work_off
80
80
 
81
81
  @user.reload
82
82
  @user.avatar.url #=> "/system/images/3/original/IMG_2772.JPG?1267562148"
@@ -1,5 +1,6 @@
1
1
  require 'delayed_paperclip/jobs'
2
2
  require 'delayed_paperclip/attachment'
3
+ require 'delayed_paperclip/url_generator'
3
4
  require 'delayed_paperclip/railtie'
4
5
 
5
6
  module DelayedPaperclip
@@ -7,7 +7,6 @@ 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 :most_appropriate_url, :processed
11
10
  base.alias_method_chain :post_process_styles, :processing
12
11
  end
13
12
 
@@ -45,14 +44,14 @@ module DelayedPaperclip
45
44
 
46
45
  def post_process_styles_with_processing(*args)
47
46
  post_process_styles_without_processing(*args)
48
- instance.update_attribute("#{name}_processing", false) if instance.respond_to?(:"#{name}_processing?")
49
47
 
50
- # instance.update_column("#{name}_processing", false) if instance.respond_to?(:"#{name}_processing?")
51
- #
52
- # if instance.respond_to?(:"#{name}_processing?")
53
- # instance.send("#{name}_processing=", false)
54
- # instance.class.update_all({ "#{name}_processing" => false }, instance.class.primary_key => instance.id)
55
- # end
48
+ # update_column is available in rails 3.1 instead we can do this to update the attribute without callbacks
49
+
50
+ #instance.update_column("#{name}_processing", false) if instance.respond_to?(:"#{name}_processing?")
51
+ if instance.respond_to?(:"#{name}_processing?")
52
+ instance.send("#{name}_processing=", false)
53
+ instance.class.update_all({ "#{name}_processing" => false }, instance.class.primary_key => instance.id)
54
+ end
56
55
  end
57
56
 
58
57
  def save_with_prepare_enqueueing
@@ -64,18 +63,6 @@ module DelayedPaperclip
64
63
  end
65
64
  end
66
65
 
67
- def most_appropriate_url_with_processed
68
- if original_filename.nil? || delayed_default_url?
69
- default_url
70
- else
71
- @options.url
72
- end
73
- end
74
-
75
- def delayed_default_url?
76
- !(job_is_processing || dirty? || !delayed_options.try(:[], :url_with_processing) || !(@instance.respond_to?(:"#{name}_processing?") && processing?))
77
- end
78
-
79
66
  end
80
67
  end
81
68
  end
@@ -17,6 +17,7 @@ module DelayedPaperclip
17
17
  def self.insert
18
18
  ActiveRecord::Base.send(:include, DelayedPaperclip::Glue)
19
19
  Paperclip::Attachment.send(:include, DelayedPaperclip::Attachment)
20
+ Paperclip::UrlGenerator.send(:include, DelayedPaperclip::UrlGenerator)
20
21
  end
21
22
  end
22
23
  end
@@ -0,0 +1,22 @@
1
+ require 'uri'
2
+ module DelayedPaperclip
3
+ module UrlGenerator
4
+ def self.included(base)
5
+ base.send :include, InstanceMethods
6
+ base.alias_method_chain :most_appropriate_url, :processed
7
+ end
8
+
9
+ def most_appropriate_url_with_processed
10
+ if @attachment.original_filename.nil? || delayed_default_url?
11
+ default_url
12
+ else
13
+ @attachment_options[:url]
14
+ end
15
+ end
16
+
17
+ def delayed_default_url?
18
+ !(@attachment.job_is_processing || @attachment.dirty? || !@attachment.delayed_options.try(:[], :url_with_processing) || !(@attachment.instance.respond_to?(:"#{@attachment.name}_processing?") && @attachment.processing?))
19
+ end
20
+ end
21
+
22
+ end
@@ -137,4 +137,14 @@ module BaseDelayedPaperclipTest
137
137
  dummy.save!
138
138
  process_jobs
139
139
  end
140
+
141
+ def test_delayed_paperclip_functioning_with_after_update_callback
142
+ reset_class "Dummy", :with_processed => true, :with_after_update_callback => true
143
+ Dummy.any_instance.expects(:reprocess)
144
+ dummy = Dummy.new(:image => File.open("#{RAILS_ROOT}/test/fixtures/12k.png"))
145
+ dummy.save!
146
+ process_jobs
147
+ dummy.update_attributes(:name => "hi")
148
+ end
149
+
140
150
  end
data/test/test_helper.rb CHANGED
@@ -41,6 +41,7 @@ end
41
41
 
42
42
  def build_dummy_table(with_processed)
43
43
  ActiveRecord::Base.connection.create_table :dummies, :force => true do |t|
44
+ t.string :name
44
45
  t.string :image_file_name
45
46
  t.string :image_content_type
46
47
  t.integer :image_file_size
@@ -57,6 +58,11 @@ def reset_class(class_name, options)
57
58
  include Paperclip::Glue
58
59
  has_attached_file :image
59
60
  process_in_background :image, options if options[:with_processed]
61
+ after_update :reprocess if options[:with_after_update_callback]
62
+
63
+ def reprocess
64
+ image.reprocess!
65
+ end
60
66
  end
61
67
  klass.reset_column_information
62
68
  klass
metadata CHANGED
@@ -1,20 +1,21 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: delayed_paperclip
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.4.5.1
4
+ version: 2.4.5.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
8
8
  - Jesse Storimer
9
9
  - Bert Goethals
10
+ - James Gifford
10
11
  autorequire:
11
12
  bindir: bin
12
13
  cert_chain: []
13
- date: 2011-11-15 00:00:00.000000000Z
14
+ date: 2012-10-07 00:00:00.000000000 Z
14
15
  dependencies:
15
16
  - !ruby/object:Gem::Dependency
16
17
  name: paperclip
17
- requirement: &2152939580 !ruby/object:Gem::Requirement
18
+ requirement: !ruby/object:Gem::Requirement
18
19
  none: false
19
20
  requirements:
20
21
  - - ! '>='
@@ -22,10 +23,15 @@ dependencies:
22
23
  version: 2.4.5
23
24
  type: :runtime
24
25
  prerelease: false
25
- version_requirements: *2152939580
26
+ version_requirements: !ruby/object:Gem::Requirement
27
+ none: false
28
+ requirements:
29
+ - - ! '>='
30
+ - !ruby/object:Gem::Version
31
+ version: 2.4.5
26
32
  - !ruby/object:Gem::Dependency
27
33
  name: mocha
28
- requirement: &2152939180 !ruby/object:Gem::Requirement
34
+ requirement: !ruby/object:Gem::Requirement
29
35
  none: false
30
36
  requirements:
31
37
  - - ! '>='
@@ -33,10 +39,15 @@ dependencies:
33
39
  version: '0'
34
40
  type: :development
35
41
  prerelease: false
36
- version_requirements: *2152939180
42
+ version_requirements: !ruby/object:Gem::Requirement
43
+ none: false
44
+ requirements:
45
+ - - ! '>='
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
37
48
  - !ruby/object:Gem::Dependency
38
49
  name: sqlite3
39
- requirement: &2152938660 !ruby/object:Gem::Requirement
50
+ requirement: !ruby/object:Gem::Requirement
40
51
  none: false
41
52
  requirements:
42
53
  - - ! '>='
@@ -44,10 +55,15 @@ dependencies:
44
55
  version: '0'
45
56
  type: :development
46
57
  prerelease: false
47
- version_requirements: *2152938660
58
+ version_requirements: !ruby/object:Gem::Requirement
59
+ none: false
60
+ requirements:
61
+ - - ! '>='
62
+ - !ruby/object:Gem::Version
63
+ version: '0'
48
64
  - !ruby/object:Gem::Dependency
49
65
  name: delayed_job
50
- requirement: &2152938180 !ruby/object:Gem::Requirement
66
+ requirement: !ruby/object:Gem::Requirement
51
67
  none: false
52
68
  requirements:
53
69
  - - ! '>='
@@ -55,10 +71,15 @@ dependencies:
55
71
  version: '0'
56
72
  type: :development
57
73
  prerelease: false
58
- version_requirements: *2152938180
74
+ version_requirements: !ruby/object:Gem::Requirement
75
+ none: false
76
+ requirements:
77
+ - - ! '>='
78
+ - !ruby/object:Gem::Version
79
+ version: '0'
59
80
  - !ruby/object:Gem::Dependency
60
81
  name: resque
61
- requirement: &2152937700 !ruby/object:Gem::Requirement
82
+ requirement: !ruby/object:Gem::Requirement
62
83
  none: false
63
84
  requirements:
64
85
  - - ! '>='
@@ -66,10 +87,15 @@ dependencies:
66
87
  version: '0'
67
88
  type: :development
68
89
  prerelease: false
69
- version_requirements: *2152937700
90
+ version_requirements: !ruby/object:Gem::Requirement
91
+ none: false
92
+ requirements:
93
+ - - ! '>='
94
+ - !ruby/object:Gem::Version
95
+ version: '0'
70
96
  description: Process your Paperclip attachments in the background with delayed_job,
71
97
  Resque or your own processor.
72
- email: jesse@jstorimer.com
98
+ email: james@jamesrgifford.com
73
99
  executables: []
74
100
  extensions: []
75
101
  extra_rdoc_files: []
@@ -78,20 +104,21 @@ files:
78
104
  - LICENSE
79
105
  - Rakefile
80
106
  - init.rb
81
- - lib/delayed_paperclip/attachment.rb
107
+ - lib/delayed_paperclip/jobs.rb
108
+ - lib/delayed_paperclip/url_generator.rb
82
109
  - lib/delayed_paperclip/jobs/delayed_job.rb
83
110
  - lib/delayed_paperclip/jobs/resque.rb
84
- - lib/delayed_paperclip/jobs.rb
111
+ - lib/delayed_paperclip/attachment.rb
85
112
  - lib/delayed_paperclip/railtie.rb
86
113
  - lib/delayed_paperclip.rb
87
- - test/base_delayed_paperclip_test.rb
88
114
  - test/database.yml
89
- - test/delayed_paperclip_test.rb
90
- - test/fixtures/12k.png
115
+ - test/base_delayed_paperclip_test.rb
91
116
  - test/resque_paperclip_test.rb
92
117
  - test/test_helper.rb
118
+ - test/fixtures/12k.png
119
+ - test/delayed_paperclip_test.rb
93
120
  - rails/init.rb
94
- homepage: http://github.com/jstorimer/delayed_paperclip
121
+ homepage: http://github.com/jrgifford/delayed_paperclip
95
122
  licenses: []
96
123
  post_install_message:
97
124
  rdoc_options: []
@@ -111,7 +138,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
111
138
  version: '0'
112
139
  requirements: []
113
140
  rubyforge_project:
114
- rubygems_version: 1.8.10
141
+ rubygems_version: 1.8.24
115
142
  signing_key:
116
143
  specification_version: 3
117
144
  summary: Process your Paperclip attachments in the background.