mbailey-paperclip 2.3.2.1 → 2.3.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -92,7 +92,7 @@ module Paperclip
92
92
  instance_write(:file_name, uploaded_file.original_filename.strip)
93
93
  instance_write(:content_type, uploaded_file.content_type.to_s.strip)
94
94
  instance_write(:file_size, uploaded_file.size.to_i)
95
- instance_write(:file_hash, uploaded_file.file_hash)
95
+ instance_write(:fingerprint, uploaded_file.fingerprint)
96
96
  instance_write(:updated_at, Time.now)
97
97
 
98
98
  @dirty = true
@@ -101,7 +101,7 @@ module Paperclip
101
101
 
102
102
  # Reset the file size if the original file was reprocessed.
103
103
  instance_write(:file_size, @queued_for_write[:original].size.to_i)
104
- instance_write(:file_hash, @queued_for_write[:original].file_hash)
104
+ instance_write(:fingerprint, @queued_for_write[:original].fingerprint)
105
105
  ensure
106
106
  uploaded_file.close if close_uploaded_file
107
107
  end
@@ -179,9 +179,9 @@ module Paperclip
179
179
  end
180
180
 
181
181
  # Returns the hash of the file as originally assigned, and lives in the
182
- # <attachment>_file_hash attribute of the model.
183
- def file_hash
184
- instance_read(:file_hash) || (@queued_for_write[:original] && @queued_for_write[:original].file_hash)
182
+ # <attachment>_fingerprint attribute of the model.
183
+ def fingerprint
184
+ instance_read(:fingerprint) || (@queued_for_write[:original] && @queued_for_write[:original].fingerprint)
185
185
  end
186
186
 
187
187
  # Returns the content_type of the file as originally assigned, and lives
@@ -88,9 +88,9 @@ module Paperclip
88
88
  attachment.instance.id
89
89
  end
90
90
 
91
- # Returns the file hash of the instance.
92
- def file_hash attachment, style_name
93
- attachment.file_hash
91
+ # Returns the fingerprint of the instance.
92
+ def fingerprint attachment, style_name
93
+ attachment.fingerprint
94
94
  end
95
95
 
96
96
  # Returns the id of the instance in a split path form. e.g. returns
@@ -34,7 +34,7 @@ module Paperclip
34
34
  end
35
35
 
36
36
  # Returns the hash of the file.
37
- def file_hash
37
+ def fingerprint
38
38
  Digest::MD5.hexdigest(self.read)
39
39
  end
40
40
  end
@@ -42,15 +42,15 @@ end
42
42
 
43
43
  if defined? StringIO
44
44
  class StringIO
45
- attr_accessor :original_filename, :content_type, :file_hash
45
+ attr_accessor :original_filename, :content_type, :fingerprint
46
46
  def original_filename
47
47
  @original_filename ||= "stringio.txt"
48
48
  end
49
49
  def content_type
50
50
  @content_type ||= "text/plain"
51
51
  end
52
- def file_hash
53
- @file_hash ||= Digest::MD5.hexdigest(self.string)
52
+ def fingerprint
53
+ @fingerprint ||= Digest::MD5.hexdigest(self.string)
54
54
  end
55
55
  end
56
56
  end
@@ -1,3 +1,3 @@
1
1
  module Paperclip
2
- VERSION = "2.3.2.1" unless defined? Paperclip::VERSION
2
+ VERSION = "2.3.3" unless defined? Paperclip::VERSION
3
3
  end
@@ -446,8 +446,8 @@ class AttachmentTest < Test::Unit::TestCase
446
446
  @not_file = mock
447
447
  @tempfile = mock
448
448
  @not_file.stubs(:nil?).returns(false)
449
- @not_file.stubs(:file_hash).returns('bd94545193321376b70136f8b223abf8')
450
- @tempfile.stubs(:file_hash).returns('bd94545193321376b70136f8b223abf8')
449
+ @not_file.stubs(:fingerprint).returns('bd94545193321376b70136f8b223abf8')
450
+ @tempfile.stubs(:fingerprint).returns('bd94545193321376b70136f8b223abf8')
451
451
  @not_file.expects(:size).returns(10)
452
452
  @tempfile.expects(:size).returns(10)
453
453
  @not_file.expects(:to_tempfile).returns(@tempfile)
@@ -757,9 +757,9 @@ class AttachmentTest < Test::Unit::TestCase
757
757
  end
758
758
  end
759
759
 
760
- context "and avatar_file_hash column" do
760
+ context "and avatar_fingerprint column" do
761
761
  setup do
762
- ActiveRecord::Base.connection.add_column :dummies, :avatar_file_hash, :string
762
+ ActiveRecord::Base.connection.add_column :dummies, :avatar_fingerprint, :string
763
763
  rebuild_class
764
764
  @dummy = Dummy.new
765
765
  end
@@ -768,16 +768,16 @@ class AttachmentTest < Test::Unit::TestCase
768
768
  assert_nothing_raised { @dummy.avatar = @file }
769
769
  end
770
770
 
771
- should "return the right value when sent #avatar_file_hash" do
771
+ should "return the right value when sent #avatar_fingerprint" do
772
772
  @dummy.avatar = @file
773
- assert_equal 'aec488126c3b33c08a10c3fa303acf27', @dummy.avatar_file_hash
773
+ assert_equal 'aec488126c3b33c08a10c3fa303acf27', @dummy.avatar_fingerprint
774
774
  end
775
775
 
776
- should "return the right value when saved, reloaded, and sent #avatar_file_hash" do
776
+ should "return the right value when saved, reloaded, and sent #avatar_fingerprint" do
777
777
  @dummy.avatar = @file
778
778
  @dummy.save
779
779
  @dummy = Dummy.find(@dummy.id)
780
- assert_equal 'aec488126c3b33c08a10c3fa303acf27', @dummy.avatar_file_hash
780
+ assert_equal 'aec488126c3b33c08a10c3fa303acf27', @dummy.avatar_fingerprint
781
781
  end
782
782
  end
783
783
  end
@@ -86,7 +86,7 @@ def rebuild_model options = {}
86
86
  table.column :avatar_content_type, :string
87
87
  table.column :avatar_file_size, :integer
88
88
  table.column :avatar_updated_at, :datetime
89
- table.column :avatar_file_hash, :string
89
+ table.column :avatar_fingerprint, :string
90
90
  end
91
91
  rebuild_class options
92
92
  end
@@ -106,7 +106,7 @@ class FakeModel
106
106
  :avatar_file_size,
107
107
  :avatar_last_updated,
108
108
  :avatar_content_type,
109
- :avatar_file_hash,
109
+ :avatar_fingerprint,
110
110
  :id
111
111
 
112
112
  def errors
metadata CHANGED
@@ -1,14 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mbailey-paperclip
3
3
  version: !ruby/object:Gem::Version
4
- hash: 125
4
+ hash: 5
5
5
  prerelease: false
6
6
  segments:
7
7
  - 2
8
8
  - 3
9
- - 2
10
- - 1
11
- version: 2.3.2.1
9
+ - 3
10
+ version: 2.3.3
12
11
  platform: ruby
13
12
  authors:
14
13
  - Jon Yurek