Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Fix] most_appropiate_url changed to be part of Paperclip::UrlGenerator,... #62

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions Appraisals
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,8 @@ end
appraise "rails3_1" do
gem "rails", "~> 3.1.0"
end

appraise "rails3_2" do
gem "rails", "~> 3.2.0"
gem "delayed_job_active_record"
end
6 changes: 4 additions & 2 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@ source "http://rubygems.org"

gemspec

gem "paperclip", '2.4.5'
gem "paperclip", '~> 2.7'

gem "appraisal"
gem "mocha"
gem "sqlite3"
gem "json", :platforms => :ruby_18

gem "delayed_job", :require => false

gem "resque", :require => false
gem "json", :platforms => :ruby_18
4 changes: 2 additions & 2 deletions gemfiles/rails2.gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@

source "http://rubygems.org"

gem "paperclip", "2.4.5"
gem "paperclip", "~> 2.7"
gem "appraisal"
gem "mocha"
gem "sqlite3"
gem "json", :platforms=>:ruby_18
gem "delayed_job", :require=>false
gem "resque", :require=>false
gem "json", :platforms=>:ruby_18
gem "rails", "~> 2.3.14"

gemspec :path=>"../"
10 changes: 5 additions & 5 deletions gemfiles/rails2.gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
PATH
remote: /Users/bertg/Development/delayed_paperclip
remote: /Users/tom/Development/Projects/delayed_paperclip
specs:
delayed_paperclip (2.4.5.0)
delayed_paperclip (2.4.5.1)
paperclip (>= 2.4.5)

GEM
Expand All @@ -20,7 +20,7 @@ GEM
appraisal (0.3.8)
bundler
rake
cocaine (0.2.0)
cocaine (0.2.1)
daemons (1.0.10)
delayed_job (2.0.7)
activesupport (~> 2.0)
Expand All @@ -31,7 +31,7 @@ GEM
mocha (0.10.0)
metaclass (~> 0.0.1)
multi_json (1.0.3)
paperclip (2.4.5)
paperclip (2.7.0)
activerecord (>= 2.3.0)
activesupport (>= 2.3.2)
cocaine (>= 0.0.2)
Expand Down Expand Up @@ -70,7 +70,7 @@ DEPENDENCIES
delayed_paperclip!
json
mocha
paperclip (= 2.4.5)
paperclip (~> 2.7)
rails (~> 2.3.14)
resque
sqlite3
4 changes: 2 additions & 2 deletions gemfiles/rails3.gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@

source "http://rubygems.org"

gem "paperclip", "2.4.5"
gem "paperclip", "~> 2.7"
gem "appraisal"
gem "mocha"
gem "sqlite3"
gem "json", :platforms=>:ruby_18
gem "delayed_job", :require=>false
gem "resque", :require=>false
gem "json", :platforms=>:ruby_18
gem "rails", "~> 3.0.10"

gemspec :path=>"../"
10 changes: 5 additions & 5 deletions gemfiles/rails3.gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
PATH
remote: /Users/bertg/Development/delayed_paperclip
remote: /Users/tom/Development/Projects/delayed_paperclip
specs:
delayed_paperclip (2.4.5.0)
delayed_paperclip (2.4.5.1)
paperclip (>= 2.4.5)

GEM
Expand Down Expand Up @@ -39,7 +39,7 @@ GEM
rake
arel (2.0.10)
builder (2.1.2)
cocaine (0.2.0)
cocaine (0.2.1)
daemons (1.1.4)
delayed_job (2.1.4)
activesupport (~> 3.0)
Expand All @@ -58,7 +58,7 @@ GEM
mocha (0.10.0)
metaclass (~> 0.0.1)
multi_json (1.0.3)
paperclip (2.4.5)
paperclip (2.7.0)
activerecord (>= 2.3.0)
activesupport (>= 2.3.2)
cocaine (>= 0.0.2)
Expand Down Expand Up @@ -116,7 +116,7 @@ DEPENDENCIES
delayed_paperclip!
json
mocha
paperclip (= 2.4.5)
paperclip (~> 2.7)
rails (~> 3.0.10)
resque
sqlite3
4 changes: 2 additions & 2 deletions gemfiles/rails3_1.gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@

source "http://rubygems.org"

gem "paperclip", "2.4.5"
gem "paperclip", "~> 2.7"
gem "appraisal"
gem "mocha"
gem "sqlite3"
gem "json", :platforms=>:ruby_18
gem "delayed_job", :require=>false
gem "resque", :require=>false
gem "json", :platforms=>:ruby_18
gem "rails", "~> 3.1.0"

gemspec :path=>"../"
10 changes: 5 additions & 5 deletions gemfiles/rails3_1.gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
PATH
remote: /Users/bertg/Development/delayed_paperclip
remote: /Users/tom/Development/Projects/delayed_paperclip
specs:
delayed_paperclip (2.4.5.0)
delayed_paperclip (2.4.5.1)
paperclip (>= 2.4.5)

GEM
Expand Down Expand Up @@ -40,7 +40,7 @@ GEM
rake
arel (2.2.1)
builder (3.0.0)
cocaine (0.2.0)
cocaine (0.2.1)
daemons (1.1.4)
delayed_job (2.1.4)
activesupport (~> 3.0)
Expand All @@ -58,7 +58,7 @@ GEM
mocha (0.10.0)
metaclass (~> 0.0.1)
multi_json (1.0.3)
paperclip (2.4.5)
paperclip (2.7.0)
activerecord (>= 2.3.0)
activesupport (>= 2.3.2)
cocaine (>= 0.0.2)
Expand Down Expand Up @@ -128,7 +128,7 @@ DEPENDENCIES
delayed_paperclip!
json
mocha
paperclip (= 2.4.5)
paperclip (~> 2.7)
rails (~> 3.1.0)
resque
sqlite3
15 changes: 15 additions & 0 deletions gemfiles/rails3_2.gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# This file was generated by Appraisal

source "http://rubygems.org"

gem "paperclip", "~> 2.7"
gem "appraisal"
gem "mocha"
gem "sqlite3"
gem "json", :platforms=>:ruby_18
gem "delayed_job", :require=>false
gem "resque", :require=>false
gem "rails", "~> 3.2.0"
gem "delayed_job_active_record"

gemspec :path=>"../"
134 changes: 134 additions & 0 deletions gemfiles/rails3_2.gemfile.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
PATH
remote: /Users/tom/Development/Projects/delayed_paperclip
specs:
delayed_paperclip (2.4.5.1)
paperclip (>= 2.4.5)

GEM
remote: http://rubygems.org/
specs:
actionmailer (3.2.2)
actionpack (= 3.2.2)
mail (~> 2.4.0)
actionpack (3.2.2)
activemodel (= 3.2.2)
activesupport (= 3.2.2)
builder (~> 3.0.0)
erubis (~> 2.7.0)
journey (~> 1.0.1)
rack (~> 1.4.0)
rack-cache (~> 1.1)
rack-test (~> 0.6.1)
sprockets (~> 2.1.2)
activemodel (3.2.2)
activesupport (= 3.2.2)
builder (~> 3.0.0)
activerecord (3.2.2)
activemodel (= 3.2.2)
activesupport (= 3.2.2)
arel (~> 3.0.2)
tzinfo (~> 0.3.29)
activeresource (3.2.2)
activemodel (= 3.2.2)
activesupport (= 3.2.2)
activesupport (3.2.2)
i18n (~> 0.6)
multi_json (~> 1.0)
appraisal (0.4.1)
bundler
rake
arel (3.0.2)
builder (3.0.0)
cocaine (0.2.1)
delayed_job (3.0.1)
activesupport (~> 3.0)
delayed_job_active_record (0.3.2)
activerecord (> 2.1.0)
delayed_job (~> 3.0.0)
erubis (2.7.0)
hike (1.2.1)
i18n (0.6.0)
journey (1.0.3)
json (1.6.5)
mail (2.4.1)
i18n (>= 0.4.0)
mime-types (~> 1.16)
treetop (~> 1.4.8)
metaclass (0.0.1)
mime-types (1.17.2)
mocha (0.10.5)
metaclass (~> 0.0.1)
multi_json (1.1.0)
paperclip (2.7.0)
activerecord (>= 2.3.0)
activesupport (>= 2.3.2)
cocaine (>= 0.0.2)
mime-types
polyglot (0.3.3)
rack (1.4.1)
rack-cache (1.1)
rack (>= 0.4)
rack-protection (1.2.0)
rack
rack-ssl (1.3.2)
rack
rack-test (0.6.1)
rack (>= 1.0)
rails (3.2.2)
actionmailer (= 3.2.2)
actionpack (= 3.2.2)
activerecord (= 3.2.2)
activeresource (= 3.2.2)
activesupport (= 3.2.2)
bundler (~> 1.0)
railties (= 3.2.2)
railties (3.2.2)
actionpack (= 3.2.2)
activesupport (= 3.2.2)
rack-ssl (~> 1.3.2)
rake (>= 0.8.7)
rdoc (~> 3.4)
thor (~> 0.14.6)
rake (0.9.2.2)
rdoc (3.12)
json (~> 1.4)
redis (2.2.2)
redis-namespace (1.0.3)
redis (< 3.0.0)
resque (1.20.0)
multi_json (~> 1.0)
redis-namespace (~> 1.0.2)
sinatra (>= 0.9.2)
vegas (~> 0.1.2)
sinatra (1.3.2)
rack (~> 1.3, >= 1.3.6)
rack-protection (~> 1.2)
tilt (~> 1.3, >= 1.3.3)
sprockets (2.1.2)
hike (~> 1.2)
rack (~> 1.0)
tilt (~> 1.1, != 1.3.0)
sqlite3 (1.3.5)
thor (0.14.6)
tilt (1.3.3)
treetop (1.4.10)
polyglot
polyglot (>= 0.3.1)
tzinfo (0.3.31)
vegas (0.1.11)
rack (>= 1.0.0)

PLATFORMS
ruby

DEPENDENCIES
appraisal
delayed_job
delayed_job_active_record
delayed_paperclip!
json
mocha
paperclip (~> 2.7)
rails (~> 3.2.0)
resque
sqlite3
1 change: 1 addition & 0 deletions lib/delayed_paperclip.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
require 'delayed_paperclip/jobs'
require 'delayed_paperclip/attachment'
require 'delayed_paperclip/url_generator'
require 'delayed_paperclip/railtie'

module DelayedPaperclip
Expand Down
17 changes: 4 additions & 13 deletions lib/delayed_paperclip/attachment.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ def self.included(base)
base.alias_method_chain :post_processing, :delay
base.alias_method_chain :post_processing=, :delay
base.alias_method_chain :save, :prepare_enqueueing
base.alias_method_chain :most_appropriate_url, :processed
base.alias_method_chain :post_process_styles, :processing
end

Expand Down Expand Up @@ -46,12 +45,10 @@ def process_delayed!
def post_process_styles_with_processing(*args)
post_process_styles_without_processing(*args)

# update_column is available in rails 3.1 instead we can do this to update the attribute without callbacks

#instance.update_column("#{name}_processing", false) if instance.respond_to?(:"#{name}_processing?")
if instance.respond_to?(:"#{name}_processing?")
instance.send("#{name}_processing=", false)
instance.class.update_all({ "#{name}_processing" => false }, instance.class.primary_key => instance.id)

instance.class.update_all({ "#{name}_processing" => false, "#{name}_updated_at" => Time.at(self.updated_at) }, instance.class.primary_key => instance.id)
end
end

Expand All @@ -64,18 +61,12 @@ def save_with_prepare_enqueueing
end
end

def most_appropriate_url_with_processed
if original_filename.nil? || delayed_default_url?
default_url
else
@options.url
end
end

def delayed_default_url?
!(job_is_processing || dirty? || !delayed_options.try(:[], :url_with_processing) || !(@instance.respond_to?(:"#{name}_processing?") && processing?))
end

end
end
end


Loading