public
Description: Paperclip File Management Plugin
Homepage: http://www.thoughtbot.com/projects/paperclip
Clone URL: git://github.com/thoughtbot/paperclip.git
Added ability for geometries to be procs
jyurek (author)
Fri May 23 07:24:09 -0700 2008
commit  91272d8767743419ac27dbc38893806a9de7470d
tree    c7051c5606c4929296c36847b81d074a7e850bb5
parent  5fdf96400afaa734735fd095919962c1fcb9bcca
...
202
203
204
 
205
206
207
...
202
203
204
205
206
207
208
0
@@ -202,6 +202,7 @@ module Paperclip
0
       @styles.each do |name, args|
0
         begin
0
           dimensions, format = args
0
+ dimensions = dimensions.call(instance) if dimensions.respond_to?(:call)
0
           @queued_for_write[name] = Thumbnail.make(@queued_for_write[:original],
0
                                                    dimensions,
0
                                                    format,
...
70
71
72
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
73
74
75
...
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
0
@@ -70,6 +70,28 @@ class AttachmentTest < Test::Unit::TestCase
0
     end
0
   end
0
 
0
+ context "An attachment with a style that is a proc" do
0
+ setup do
0
+ rebuild_model :styles => {:custom => proc{|i| "#{i.width}x#{i.height}#{i.modifier}"}}
0
+ Dummy.class_eval do
0
+ attr_accessor :height, :width, :modifier
0
+ end
0
+ @dummy = Dummy.new
0
+ @file = File.new(File.join(File.dirname(__FILE__),
0
+ "fixtures",
0
+ "5k.png"))
0
+ end
0
+
0
+ should "create a thumbnail with size 100x1000!" do
0
+ @dummy.height = 1000
0
+ @dummy.width = 100
0
+ @dummy.modifier = "!"
0
+ @dummy.avatar = @file
0
+ assert @dummy.save
0
+ assert_match(/100x1000/, `identify #{@dummy.avatar.path(:custom)}`)
0
+ end
0
+ end
0
+
0
   context "An attachment with similarly named interpolations" do
0
     setup do
0
       rebuild_model :path => ":id.omg/:id-bbq/:idwhat/:id_partition.wtf"

Comments

    No one has commented yet.