public
Description: Treat an ActiveRecord model as a file attachment, storing its patch, size, content type, etc.
Homepage: http://weblog.techno-weenie.net
Clone URL: git://github.com/technoweenie/attachment_fu.git
Click here to lend your support to: attachment_fu and make a donation at www.pledgie.com !
refactor tempfile usage since the block was being skipped for something
rick (author)
Mon Apr 28 17:42:05 -0700 2008
commit  e19754b2143604c08cd0a9a8dbc5b889205b3f99
tree    1d624df7782136b50d04b1adc60c697db18c0961
parent  b886be8a4c49e3b252a153771bd33c5cf9ee0c89
...
128
129
130
131
132
133
 
 
 
 
134
135
136
...
128
129
130
 
 
 
131
132
133
134
135
136
137
0
@@ -128,9 +128,10 @@ module AttachmentFu
0
       self.filename = file_data.original_filename
0
       if file_data.respond_to?(:rewind) # it's an IO object
0
         file_data.rewind
0
- self.temp_path = Tempfile.new filename do |f|
0
- f << file_data.read
0
- end
0
+ self.temp_path = Tempfile.new(filename)
0
+ temp_path.binmode
0
+ temp_path << file_data.read
0
+ temp_path.rewind
0
       else
0
         self.temp_path = file_data
0
       end
...
27
28
29
30
31
 
 
 
32
...
27
28
29
 
30
31
32
33
34
0
@@ -27,4 +27,6 @@ module AttachmentFu
0
       end
0
     end
0
   end
0
-end
0
\ No newline at end of file
0
+end
0
+
0
+send respond_to?(:require_dependency) ? :require_dependency : :require, "attachment_fu/geometry"
0
\ No newline at end of file
...
141
142
143
 
144
145
146
...
173
174
175
 
176
177
178
...
141
142
143
144
145
146
147
...
174
175
176
177
178
179
180
0
@@ -141,6 +141,7 @@ module AttachmentFu
0
         it "sets temp_path as string path to file" do
0
           @asset.uploaded_data = @file
0
           @asset.temp_path.should == __FILE__
0
+ @asset.temp_path.size.should == File.size(__FILE__)
0
         end
0
 
0
         it "sets content_type" do
0
@@ -173,6 +174,7 @@ module AttachmentFu
0
         it "sets temp_path as Tempfile" do
0
           @asset.uploaded_data = @file
0
           @asset.temp_path.class.should == Tempfile
0
+ @asset.temp_path.size.should == File.size(__FILE__)
0
         end
0
 
0
         it "sets content_type" do

Comments

    No one has commented yet.