korobkov-paperclip 2.3.1.200909221741 → 2.3.1.200909222157

Sign up to get free protection for your applications and to get access to all the features.
@@ -347,7 +347,6 @@ module Paperclip
347
347
  end
348
348
 
349
349
  # Set it all up.
350
- if Object.const_defined?("ActiveRecord")
351
- ActiveRecord::Base.send(:include, Paperclip)
352
- File.send(:include, Paperclip::Upfile)
353
- end
350
+ ActiveRecord::Base.send(:include, Paperclip) if Object.const_defined?("ActiveRecord")
351
+ Tempfile.send(:include, Paperclip::Upfile)
352
+ File.send(:include, Paperclip::Upfile)
@@ -80,7 +80,7 @@ module Paperclip
80
80
 
81
81
  @queued_for_write[:original] = uploaded_file.to_tempfile
82
82
  instance_write(:file_name, uploaded_file.original_filename.strip.gsub(/[^A-Za-z\d\.\-_]+/, '_'))
83
- instance_write(:content_type, uploaded_file.content_type.strip)
83
+ instance_write(:content_type, uploaded_file.content_type)
84
84
  instance_write(:file_size, uploaded_file.size.to_i)
85
85
  instance_write(:file_hexdigest, uploaded_file.hexdigest)
86
86
  instance_write(:updated_at, Time.now)
@@ -9,7 +9,11 @@ module Paperclip
9
9
 
10
10
  # Infer the MIME-type of the file from the magic.
11
11
  def content_type
12
- MimeMagic.by_magic(self).type || "application/octet-stream"
12
+ unless MimeMagic.by_magic(self).nil?
13
+ MimeMagic.by_magic(self).type
14
+ else
15
+ "application/octet-stream"
16
+ end
13
17
  end
14
18
 
15
19
  # Returns the file's normal name.
@@ -40,8 +44,3 @@ if defined? StringIO
40
44
  end
41
45
  end
42
46
  end
43
-
44
- class File #:nodoc:
45
- include Paperclip::Upfile
46
- end
47
-
@@ -54,7 +54,7 @@ namespace :paperclip do
54
54
  for_all_attachments do |instance, name|
55
55
  if file = instance.send(name).to_file
56
56
  instance.send("#{name}_file_name=", instance.send("#{name}_file_name").strip)
57
- instance.send("#{name}_content_type=", file.content_type.strip)
57
+ instance.send("#{name}_content_type=", file.content_type)
58
58
  instance.send("#{name}_file_size=", file.size) if instance.respond_to?("#{name}_file_size")
59
59
  instance.send("#{name}_file_hexdigest=", file.hexdigest) if instance.respond_to?("#{name}_file_hexdigest")
60
60
  instance.save(false)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: korobkov-paperclip
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.3.1.200909221741
4
+ version: 2.3.1.200909222157
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jon Yurek