Commit c7b802cb by Jon Yurek

Deprecations: Interpolation definition and thumbnail validation

parent acc8f754
...@@ -64,7 +64,6 @@ spec = Gem::Specification.new do |s| ...@@ -64,7 +64,6 @@ spec = Gem::Specification.new do |s|
s.extra_rdoc_files = FileList["README*"].to_a s.extra_rdoc_files = FileList["README*"].to_a
s.rdoc_options << '--line-numbers' << '--inline-source' s.rdoc_options << '--line-numbers' << '--inline-source'
s.requirements << "ImageMagick" s.requirements << "ImageMagick"
s.add_runtime_dependency 'right_aws'
s.add_development_dependency 'thoughtbot-shoulda' s.add_development_dependency 'thoughtbot-shoulda'
s.add_development_dependency 'mocha' s.add_development_dependency 'mocha'
end end
......
...@@ -75,7 +75,7 @@ module Paperclip ...@@ -75,7 +75,7 @@ module Paperclip
end end
def interpolates key, &block def interpolates key, &block
Paperclip::Attachment.interpolations[key] = block Paperclip::Interpolations[key] = block
end end
# The run method takes a command to execute and a string of parameters # The run method takes a command to execute and a string of parameters
...@@ -235,6 +235,9 @@ module Paperclip ...@@ -235,6 +235,9 @@ module Paperclip
# Adds errors if thumbnail creation fails. The same as specifying :whiny_thumbnails => true. # Adds errors if thumbnail creation fails. The same as specifying :whiny_thumbnails => true.
def validates_attachment_thumbnails name, options = {} def validates_attachment_thumbnails name, options = {}
warn('[DEPRECATED] validates_attachment_thumbnail is deprecated. '
'This validation is on by default and will be removed from future versions. '
'If you wish to turn it off, supply :whiny => false in your definition.')
attachment_definitions[name][:whiny_thumbnails] = true attachment_definitions[name][:whiny_thumbnails] = true
end end
......
...@@ -37,7 +37,8 @@ module Paperclip ...@@ -37,7 +37,8 @@ module Paperclip
@validations = options[:validations] @validations = options[:validations]
@default_style = options[:default_style] @default_style = options[:default_style]
@storage = options[:storage] @storage = options[:storage]
@whiny = options[:whiny_thumbnails] @whiny = options[:whiny_thumbnails] || options[:whiny]
@whiny = true unless @whiny == false # default to true if nil
@convert_options = options[:convert_options] || {} @convert_options = options[:convert_options] || {}
@processors = options[:processors] || [:thumbnail] @processors = options[:processors] || [:thumbnail]
@options = options @options = options
...@@ -198,6 +199,9 @@ module Paperclip ...@@ -198,6 +199,9 @@ module Paperclip
# style as arguments. This hash can be added to with your own proc if # style as arguments. This hash can be added to with your own proc if
# necessary. # necessary.
def self.interpolations def self.interpolations
warn('[DEPRECATION] Paperclip::Attachment.interpolations is deprecated '
'and will be removed from future versions. '
'Use Paperclip.interpolates instead')
Paperclip::Interpolations Paperclip::Interpolations
end end
......
...@@ -140,13 +140,13 @@ module Paperclip ...@@ -140,13 +140,13 @@ module Paperclip
@s3_host_alias = @options[:s3_host_alias] @s3_host_alias = @options[:s3_host_alias]
@url = ":s3_path_url" unless @url.to_s.match(/^:s3.*url$/) @url = ":s3_path_url" unless @url.to_s.match(/^:s3.*url$/)
end end
base.class.interpolations[:s3_alias_url] = lambda do |attachment, style| Paperclip.interpolates(:s3_alias_url) do |attachment, style|
"#{attachment.s3_protocol}://#{attachment.s3_host_alias}/#{attachment.path(style).gsub(%r{^/}, "")}" "#{attachment.s3_protocol}://#{attachment.s3_host_alias}/#{attachment.path(style).gsub(%r{^/}, "")}"
end end
base.class.interpolations[:s3_path_url] = lambda do |attachment, style| Paperclip.interpolates(:s3_path_url) do |attachment, style|
"#{attachment.s3_protocol}://s3.amazonaws.com/#{attachment.bucket_name}/#{attachment.path(style).gsub(%r{^/}, "")}" "#{attachment.s3_protocol}://s3.amazonaws.com/#{attachment.bucket_name}/#{attachment.path(style).gsub(%r{^/}, "")}"
end end
base.class.interpolations[:s3_domain_url] = lambda do |attachment, style| Paperclip.interpolates(:s3_domain_url) do |attachment, style|
"#{attachment.s3_protocol}://#{attachment.bucket_name}.s3.amazonaws.com/#{attachment.path(style).gsub(%r{^/}, "")}" "#{attachment.s3_protocol}://#{attachment.bucket_name}.s3.amazonaws.com/#{attachment.path(style).gsub(%r{^/}, "")}"
end end
end end
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment