dm-paperclip 2.1.2 → 2.1.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/init.rb +1 -2
- data/lib/dm-paperclip.rb +4 -8
- data/lib/dm-paperclip/attachment.rb +19 -6
- data/test/helper.rb +5 -0
- metadata +1 -1
data/init.rb
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
require File.join(File.dirname(__FILE__), 'lib', 'dm-paperclip')
|
|
2
|
-
File.send :include, Paperclip::Upfile
|
|
1
|
+
require File.join(File.dirname(__FILE__), 'lib', 'dm-paperclip')
|
data/lib/dm-paperclip.rb
CHANGED
|
@@ -37,7 +37,7 @@ require File.join(File.dirname(__FILE__), 'dm-paperclip', 'attachment')
|
|
|
37
37
|
require File.join(File.dirname(__FILE__), 'dm-paperclip', 'validations') unless defined?(DataMapper::Validate).nil?
|
|
38
38
|
|
|
39
39
|
module Paperclip
|
|
40
|
-
VERSION = "2.1.2"
|
|
40
|
+
VERSION = "2.1.2.1"
|
|
41
41
|
class << self
|
|
42
42
|
# Provides configurability to Paperclip. There are a number of options available, such as:
|
|
43
43
|
# * whiny_thumbnails: Will raise an error if Paperclip cannot process thumbnails of
|
|
@@ -214,16 +214,12 @@ module Paperclip
|
|
|
214
214
|
|
|
215
215
|
def destroy_attached_files
|
|
216
216
|
each_attachment do |name, attachment|
|
|
217
|
-
attachment.queue_existing_for_delete
|
|
218
|
-
attachment.flush_deletes
|
|
217
|
+
attachment.send(:queue_existing_for_delete)
|
|
218
|
+
attachment.send(:flush_deletes)
|
|
219
219
|
end
|
|
220
220
|
end
|
|
221
221
|
end
|
|
222
222
|
|
|
223
223
|
end
|
|
224
224
|
|
|
225
|
-
|
|
226
|
-
if Object.const_defined?("ActiveRecord")
|
|
227
|
-
ActiveRecord::Base.send(:include, Paperclip)
|
|
228
|
-
File.send(:include, Paperclip::Upfile)
|
|
229
|
-
end
|
|
225
|
+
File.send(:include, Paperclip::Upfile)
|
|
@@ -57,11 +57,19 @@ module Paperclip
|
|
|
57
57
|
|
|
58
58
|
return nil if uploaded_file.nil?
|
|
59
59
|
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
60
|
+
if uploaded_file.is_a?(Mash)
|
|
61
|
+
@queued_for_write[:original] = uploaded_file['tempfile']
|
|
62
|
+
newvals = { :"#{@name}_file_name" => uploaded_file['filename'],
|
|
63
|
+
:"#{@name}_content_type" => uploaded_file['content_type'],
|
|
64
|
+
:"#{@name}_file_size" => uploaded_file['size'] }
|
|
65
|
+
@instance.update_attributes(newvals)
|
|
66
|
+
else
|
|
67
|
+
@queued_for_write[:original] = uploaded_file.to_tempfile
|
|
68
|
+
newvals = { :"#{@name}_file_name" => uploaded_file.original_filename,
|
|
69
|
+
:"#{@name}_content_type" => uploaded_file.content_type,
|
|
70
|
+
:"#{@name}_file_size" => uploaded_file.size }
|
|
71
|
+
@instance.update_attributes(newvals)
|
|
72
|
+
end
|
|
65
73
|
|
|
66
74
|
@dirty = true
|
|
67
75
|
|
|
@@ -181,7 +189,12 @@ module Paperclip
|
|
|
181
189
|
end
|
|
182
190
|
|
|
183
191
|
def valid_assignment? file #:nodoc:
|
|
184
|
-
|
|
192
|
+
return true if file.nil?
|
|
193
|
+
if(file.is_a?(File))
|
|
194
|
+
(file.respond_to?(:original_filename) && file.respond_to?(:content_type))
|
|
195
|
+
elsif(file.is_a?(Mash))
|
|
196
|
+
(file.include?('tempfile') && file.include?('content_type') && file.include?('size') && file.include?('filename'))
|
|
197
|
+
end
|
|
185
198
|
end
|
|
186
199
|
|
|
187
200
|
def validate #:nodoc:
|
data/test/helper.rb
CHANGED
|
@@ -36,6 +36,11 @@ ENV['RAILS_ENV'] ||= 'test'
|
|
|
36
36
|
FIXTURES_DIR = File.join(File.dirname(__FILE__), "fixtures")
|
|
37
37
|
DataMapper.setup(:default, 'sqlite3::memory:')
|
|
38
38
|
|
|
39
|
+
unless defined?(Mash)
|
|
40
|
+
class Mash < Hash
|
|
41
|
+
end
|
|
42
|
+
end
|
|
43
|
+
|
|
39
44
|
def rebuild_model options = {}
|
|
40
45
|
DataMapper::Migration.new( 1, :drop_dummies_table ) do
|
|
41
46
|
up do
|