paperclip 3.3.0 → 3.3.1
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of paperclip might be problematic. Click here for more details.
- data/NEWS +8 -0
- data/README.md +26 -16
- data/lib/paperclip/attachment.rb +4 -4
- data/lib/paperclip/io_adapters/abstract_adapter.rb +6 -0
- data/lib/paperclip/io_adapters/stringio_adapter.rb +2 -1
- data/lib/paperclip/io_adapters/uri_adapter.rb +2 -1
- data/lib/paperclip/storage/filesystem.rb +3 -3
- data/lib/paperclip/storage/fog.rb +1 -1
- data/lib/paperclip/version.rb +1 -1
- data/paperclip.gemspec +1 -1
- data/test/helper.rb +1 -0
- data/test/io_adapters/abstract_adapter_test.rb +8 -1
- data/test/storage/filesystem_test.rb +8 -0
- data/test/storage/fog_test.rb +11 -0
- metadata +10 -4
data/NEWS
CHANGED
data/README.md
CHANGED
@@ -42,7 +42,9 @@ directory to its path.
|
|
42
42
|
|
43
43
|
In development mode, you might add this line to `config/environments/development.rb)`:
|
44
44
|
|
45
|
-
|
45
|
+
```ruby
|
46
|
+
Paperclip.options[:command_path] = "/usr/local/bin/"
|
47
|
+
```
|
46
48
|
|
47
49
|
If you're on Mac OS X, you'll want to run the following with Homebrew:
|
48
50
|
|
@@ -61,15 +63,21 @@ Paperclip is distributed as a gem, which is how it should be used in your app.
|
|
61
63
|
|
62
64
|
Include the gem in your Gemfile:
|
63
65
|
|
64
|
-
|
66
|
+
```ruby
|
67
|
+
gem "paperclip", "~> 3.0"
|
68
|
+
```
|
65
69
|
|
66
70
|
If you're still using Rails 2.3.x, you should do this instead:
|
67
71
|
|
68
|
-
|
72
|
+
```ruby
|
73
|
+
gem "paperclip", "~> 2.7"
|
74
|
+
```
|
69
75
|
|
70
76
|
Or, if you want to get the latest, you can get master from the main paperclip repository:
|
71
77
|
|
72
|
-
|
78
|
+
```ruby
|
79
|
+
gem "paperclip", :git => "git://github.com/thoughtbot/paperclip.git"
|
80
|
+
```
|
73
81
|
|
74
82
|
If you're trying to use features that don't seem to be in the latest released gem, but are
|
75
83
|
mentioned in this README, then you probably need to specify the master branch if you want to
|
@@ -567,18 +575,20 @@ end
|
|
567
575
|
|
568
576
|
Then in `RAILS_ROOT/public/system/paperclip_attachments.yml`:
|
569
577
|
|
570
|
-
|
571
|
-
|
572
|
-
|
573
|
-
|
574
|
-
|
575
|
-
|
576
|
-
|
577
|
-
|
578
|
-
|
579
|
-
|
580
|
-
|
581
|
-
|
578
|
+
```yml
|
579
|
+
---
|
580
|
+
:User:
|
581
|
+
:avatar:
|
582
|
+
- :thumb
|
583
|
+
- :croppable
|
584
|
+
- :big
|
585
|
+
:Book:
|
586
|
+
:cover:
|
587
|
+
- :small
|
588
|
+
- :large
|
589
|
+
:sample:
|
590
|
+
- :thumb
|
591
|
+
```
|
582
592
|
|
583
593
|
Testing
|
584
594
|
-------
|
data/lib/paperclip/attachment.rb
CHANGED
@@ -46,7 +46,7 @@ module Paperclip
|
|
46
46
|
# +styles+ - a hash of options for processing the attachment. See +has_attached_file+ for the details
|
47
47
|
# +only_process+ - style args to be run through the post-processor. This defaults to the empty list
|
48
48
|
# +default_url+ - a URL for the missing image
|
49
|
-
# +default_style+ - the style to use when
|
49
|
+
# +default_style+ - the style to use when an argument is not specified e.g. #url, #path
|
50
50
|
# +storage+ - the storage mechanism. Defaults to :filesystem
|
51
51
|
# +use_timestamp+ - whether to append an anti-caching timestamp to image URLs. Defaults to true
|
52
52
|
# +whiny+, +whiny_thumbnails+ - whether to raise when thumbnailing fails
|
@@ -57,7 +57,7 @@ module Paperclip
|
|
57
57
|
# +convert_options+ - flags passed to the +convert+ command for processing
|
58
58
|
# +source_file_options+ - flags passed to the +convert+ command that controls how the file is read
|
59
59
|
# +processors+ - classes that transform the attachment. Defaults to [:thumbnail]
|
60
|
-
# +preserve_files+ - whether to keep files on the filesystem when deleting
|
60
|
+
# +preserve_files+ - whether to keep files on the filesystem when deleting or clearing the attachment. Defaults to false
|
61
61
|
# +interpolator+ - the object used to interpolate filenames and URLs. Defaults to Paperclip::Interpolations
|
62
62
|
# +url_generator+ - the object used to generate URLs, using the interpolator. Defaults to Paperclip::UrlGenerator
|
63
63
|
def initialize(name, instance, options = {})
|
@@ -167,7 +167,7 @@ module Paperclip
|
|
167
167
|
styles = styles.call(self) if styles.respond_to?(:call)
|
168
168
|
|
169
169
|
@normalized_styles = styles.dup
|
170
|
-
|
170
|
+
styles.each_pair do |name, options|
|
171
171
|
@normalized_styles[name.to_sym] = Paperclip::Style.new(name.to_sym, options.dup, self)
|
172
172
|
end
|
173
173
|
end
|
@@ -244,7 +244,7 @@ module Paperclip
|
|
244
244
|
end
|
245
245
|
|
246
246
|
# Returns the fingerprint of the file, if one's defined. The fingerprint is
|
247
|
-
# stored in the <attachment>
|
247
|
+
# stored in the <attachment>_fingerprint attribute of the model.
|
248
248
|
def fingerprint
|
249
249
|
instance_read(:fingerprint)
|
250
250
|
end
|
@@ -2,6 +2,8 @@ require 'active_support/core_ext/module/delegation'
|
|
2
2
|
|
3
3
|
module Paperclip
|
4
4
|
class AbstractAdapter
|
5
|
+
OS_RESTRICTED_CHARACTERS = %r{[/:]}
|
6
|
+
|
5
7
|
attr_reader :content_type, :original_filename, :size
|
6
8
|
delegate :close, :closed?, :eof?, :path, :rewind, :unlink, :to => :@tempfile
|
7
9
|
|
@@ -17,6 +19,10 @@ module Paperclip
|
|
17
19
|
"#{self.class}: #{self.original_filename}"
|
18
20
|
end
|
19
21
|
|
22
|
+
def original_filename=(new_filename)
|
23
|
+
@original_filename = new_filename.gsub(OS_RESTRICTED_CHARACTERS, "_")
|
24
|
+
end
|
25
|
+
|
20
26
|
private
|
21
27
|
|
22
28
|
def destination
|
@@ -67,10 +67,10 @@ module Paperclip
|
|
67
67
|
end
|
68
68
|
@queued_for_delete = []
|
69
69
|
end
|
70
|
-
end
|
71
70
|
|
72
|
-
|
73
|
-
|
71
|
+
def copy_to_local_file(style, local_dest_path)
|
72
|
+
FileUtils.cp(path(style), local_dest_path)
|
73
|
+
end
|
74
74
|
end
|
75
75
|
|
76
76
|
end
|
data/lib/paperclip/version.rb
CHANGED
data/paperclip.gemspec
CHANGED
@@ -43,7 +43,7 @@ Gem::Specification.new do |s|
|
|
43
43
|
s.add_development_dependency('capybara')
|
44
44
|
s.add_development_dependency('bundler')
|
45
45
|
s.add_development_dependency('cocaine', '~> 0.2')
|
46
|
-
s.add_development_dependency('fog', '
|
46
|
+
s.add_development_dependency('fog', '>= 1.4.0', "< 1.7.0")
|
47
47
|
s.add_development_dependency('pry')
|
48
48
|
s.add_development_dependency('launchy')
|
49
49
|
s.add_development_dependency('rake')
|
data/test/helper.rb
CHANGED
@@ -2,7 +2,7 @@ require './test/helper'
|
|
2
2
|
|
3
3
|
class AbstractAdapterTest < Test::Unit::TestCase
|
4
4
|
class TestAdapter < Paperclip::AbstractAdapter
|
5
|
-
attr_accessor :
|
5
|
+
attr_accessor :tempfile
|
6
6
|
|
7
7
|
def content_type
|
8
8
|
Paperclip::ContentTypeDetector.new(path).detect
|
@@ -40,4 +40,11 @@ class AbstractAdapterTest < Test::Unit::TestCase
|
|
40
40
|
end
|
41
41
|
end
|
42
42
|
end
|
43
|
+
|
44
|
+
should 'get rid of slashes and colons in filenames' do
|
45
|
+
@adapter = TestAdapter.new
|
46
|
+
@adapter.original_filename = "awesome/file:name.png"
|
47
|
+
|
48
|
+
assert_equal "awesome_file_name.png", @adapter.original_filename
|
49
|
+
end
|
43
50
|
end
|
@@ -41,6 +41,14 @@ class FileSystemTest < Test::Unit::TestCase
|
|
41
41
|
assert paths.none?{ |path| File.exists?(path) },
|
42
42
|
"Expect all the files to be deleted."
|
43
43
|
end
|
44
|
+
|
45
|
+
should 'copy the file to a known location with copy_to_local_file' do
|
46
|
+
tempfile = Tempfile.new("known_location")
|
47
|
+
@dummy.avatar.copy_to_local_file(:original, tempfile.path)
|
48
|
+
tempfile.rewind
|
49
|
+
assert_equal @file.read, tempfile.read
|
50
|
+
tempfile.close
|
51
|
+
end
|
44
52
|
end
|
45
53
|
|
46
54
|
context "with file that has space in file name" do
|
data/test/storage/fog_test.rb
CHANGED
@@ -149,6 +149,17 @@ class FogTest < Test::Unit::TestCase
|
|
149
149
|
"Expect all the files to be deleted."
|
150
150
|
end
|
151
151
|
|
152
|
+
should 'be able to be copied to a local file' do
|
153
|
+
@dummy.save
|
154
|
+
tempfile = Tempfile.new("known_location")
|
155
|
+
tempfile.binmode
|
156
|
+
@dummy.avatar.copy_to_local_file(:original, tempfile.path)
|
157
|
+
tempfile.rewind
|
158
|
+
assert_equal @connection.directories.get(@fog_directory).files.get(@dummy.avatar.path).body,
|
159
|
+
tempfile.read
|
160
|
+
tempfile.close
|
161
|
+
end
|
162
|
+
|
152
163
|
should "pass the content type to the Fog::Storage::AWS::Files instance" do
|
153
164
|
Fog::Storage::AWS::Files.any_instance.expects(:create).with do |hash|
|
154
165
|
hash[:content_type]
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: paperclip
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.3.
|
4
|
+
version: 3.3.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-10-
|
12
|
+
date: 2012-10-31 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activerecord
|
@@ -288,17 +288,23 @@ dependencies:
|
|
288
288
|
requirement: !ruby/object:Gem::Requirement
|
289
289
|
none: false
|
290
290
|
requirements:
|
291
|
-
- -
|
291
|
+
- - ! '>='
|
292
292
|
- !ruby/object:Gem::Version
|
293
293
|
version: 1.4.0
|
294
|
+
- - <
|
295
|
+
- !ruby/object:Gem::Version
|
296
|
+
version: 1.7.0
|
294
297
|
type: :development
|
295
298
|
prerelease: false
|
296
299
|
version_requirements: !ruby/object:Gem::Requirement
|
297
300
|
none: false
|
298
301
|
requirements:
|
299
|
-
- -
|
302
|
+
- - ! '>='
|
300
303
|
- !ruby/object:Gem::Version
|
301
304
|
version: 1.4.0
|
305
|
+
- - <
|
306
|
+
- !ruby/object:Gem::Version
|
307
|
+
version: 1.7.0
|
302
308
|
- !ruby/object:Gem::Dependency
|
303
309
|
name: pry
|
304
310
|
requirement: !ruby/object:Gem::Requirement
|