Skip to content

Commit

Permalink
Deprecations: Interpolation definition and thumbnail validation
Browse files Browse the repository at this point in the history
  • Loading branch information
Jon Yurek committed May 7, 2009
1 parent acc8f75 commit c7b802c
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 6 deletions.
1 change: 0 additions & 1 deletion Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ spec = Gem::Specification.new do |s|
s.extra_rdoc_files = FileList["README*"].to_a
s.rdoc_options << '--line-numbers' << '--inline-source'
s.requirements << "ImageMagick"
s.add_runtime_dependency 'right_aws'
s.add_development_dependency 'thoughtbot-shoulda'
s.add_development_dependency 'mocha'
end
Expand Down
5 changes: 4 additions & 1 deletion lib/paperclip.rb
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ def path_for_command command #:nodoc:
end

def interpolates key, &block
Paperclip::Attachment.interpolations[key] = block
Paperclip::Interpolations[key] = block
end

# The run method takes a command to execute and a string of parameters
Expand Down Expand Up @@ -235,6 +235,9 @@ def validates_attachment_size name, options = {}

# Adds errors if thumbnail creation fails. The same as specifying :whiny_thumbnails => true.
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
end

Expand Down
6 changes: 5 additions & 1 deletion lib/paperclip/attachment.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ def initialize name, instance, options = {}
@validations = options[:validations]
@default_style = options[:default_style]
@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] || {}
@processors = options[:processors] || [:thumbnail]
@options = options
Expand Down Expand Up @@ -198,6 +199,9 @@ def updated_at
# style as arguments. This hash can be added to with your own proc if
# necessary.
def self.interpolations
warn('[DEPRECATION] Paperclip::Attachment.interpolations is deprecated '
'and will be removed from future versions. '
'Use Paperclip.interpolates instead')
Paperclip::Interpolations
end

Expand Down
6 changes: 3 additions & 3 deletions lib/paperclip/storage.rb
Original file line number Diff line number Diff line change
Expand Up @@ -140,13 +140,13 @@ def self.extended base
@s3_host_alias = @options[:s3_host_alias]
@url = ":s3_path_url" unless @url.to_s.match(/^:s3.*url$/)
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{^/}, "")}"
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{^/}, "")}"
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{^/}, "")}"
end
end
Expand Down

0 comments on commit c7b802c

Please sign in to comment.