paperclip 5.2.1 → 5.3.0
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.
- checksums.yaml +4 -4
- data/NEWS +15 -0
- data/README.md +24 -12
- data/lib/generators/paperclip/paperclip_generator.rb +9 -1
- data/lib/generators/paperclip/templates/paperclip_migration.rb.erb +1 -1
- data/lib/paperclip.rb +1 -1
- data/lib/paperclip/file_command_content_type_detector.rb +1 -1
- data/lib/paperclip/geometry_detector_factory.rb +2 -2
- data/lib/paperclip/helpers.rb +3 -3
- data/lib/paperclip/io_adapters/abstract_adapter.rb +5 -1
- data/lib/paperclip/media_type_spoof_detector.rb +3 -2
- data/lib/paperclip/storage/fog.rb +2 -1
- data/lib/paperclip/storage/s3.rb +2 -1
- data/lib/paperclip/thumbnail.rb +4 -4
- data/lib/paperclip/url_generator.rb +1 -0
- data/lib/paperclip/version.rb +1 -1
- data/paperclip.gemspec +1 -1
- data/spec/paperclip/content_type_detector_spec.rb +1 -1
- data/spec/paperclip/file_command_content_type_detector_spec.rb +15 -1
- data/spec/paperclip/io_adapters/abstract_adapter_spec.rb +31 -0
- data/spec/paperclip/media_type_spoof_detector_spec.rb +15 -0
- data/spec/paperclip/paperclip_spec.rb +13 -13
- data/spec/paperclip/processor_spec.rb +4 -4
- data/spec/paperclip/storage/fog_spec.rb +5 -0
- data/spec/paperclip/thumbnail_spec.rb +3 -3
- metadata +112 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 823fa4ed80655c6ae50b1d241142e5afb3ed9e22
|
4
|
+
data.tar.gz: bb9ceacd62b0e1f6167f6d0c6392a696b788ca73
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4e5b7a64e9db33be68a6a5b8467a8df6c074d16990e51c93bea5a070896b2ce3905ccdc0cad6323148229f3a03209974791a90234d948bb65f7f85868cab35f2
|
7
|
+
data.tar.gz: 376768f292bdc225375aee8dce8c22b58e22904dabbf5044a7a2383b760b362e7a39830e9c63091e5ff1774b49ecd6f1dfbfdb293f198c66f80d3d8bb1fe1987
|
data/NEWS
CHANGED
@@ -1,3 +1,17 @@
|
|
1
|
+
5.3.0 (2018-03-09):
|
2
|
+
|
3
|
+
* Improvement: Use `FactoryBot` instead of `FactoryGirl` (https://github.com/thoughtbot/paperclip/pull/2501)
|
4
|
+
* Improvement: README updates (https://github.com/thoughtbot/paperclip/pull/2411, https://github.com/thoughtbot/paperclip/pull/2433, https://github.com/thoughtbot/paperclip/pull/2374, https://github.com/thoughtbot/paperclip/pull/2417, https://github.com/thoughtbot/paperclip/pull/2536)
|
5
|
+
* Improvement: Remove Ruby 2.4 deprecation warning (https://github.com/thoughtbot/paperclip/pull/2401)
|
6
|
+
* Improvement: Rails 5 migration compatibility (https://github.com/thoughtbot/paperclip/pull/2470)
|
7
|
+
* Improvement: Documentation around post processing (https://github.com/thoughtbot/paperclip/pull/2381)
|
8
|
+
* Improvement: S3 hostname example documentation (https://github.com/thoughtbot/paperclip/pull/2379)
|
9
|
+
* Bugfix: Allow paperclip to load in IRB (https://github.com/thoughtbot/paperclip/pull/2369)
|
10
|
+
* Bugfix: MIME type detection (https://github.com/thoughtbot/paperclip/issues/2527)
|
11
|
+
* Bugfix: Bad tempfile state after symlink failure (https://github.com/thoughtbot/paperclip/pull/2540)
|
12
|
+
* Bugfix: Rewind file after Fog bucket creation (https://github.com/thoughtbot/paperclip/pull/2572)
|
13
|
+
* Improvement: Use `Terrapin` instead of `Cocaine` (https://github.com/thoughtbot/paperclip/pull/2553)
|
14
|
+
|
1
15
|
5.2.1 (2018-01-25):
|
2
16
|
|
3
17
|
* Bugfix: Fix copying files on Windows. (#2532)
|
@@ -36,6 +50,7 @@
|
|
36
50
|
* Improvement: S3 storage option `:s3_prefixes_in_alias`. (#2287)
|
37
51
|
* Improvement: Fog option `:fog_public` can be a lambda. (#2302)
|
38
52
|
* Improvement: One fewer warning on JRuby. (#2352)
|
53
|
+
* Ruby 2.4.0 compatibility (doesn't use Fixnum anymore)
|
39
54
|
|
40
55
|
5.1.0 (2016-08-19):
|
41
56
|
|
data/README.md
CHANGED
@@ -87,7 +87,7 @@ Requirements
|
|
87
87
|
### Ruby and Rails
|
88
88
|
|
89
89
|
Paperclip now requires Ruby version **>= 2.1** and Rails version **>= 4.2**
|
90
|
-
(only if you're going to use Paperclip with Ruby on Rails.
|
90
|
+
(only if you're going to use Paperclip with Ruby on Rails).
|
91
91
|
|
92
92
|
### Image Processor
|
93
93
|
|
@@ -105,7 +105,7 @@ In development mode, you might add this line to `config/environments/development
|
|
105
105
|
Paperclip.options[:command_path] = "/usr/local/bin/"
|
106
106
|
```
|
107
107
|
|
108
|
-
If you're on Mac OS X, you'll want to run the following with [Homebrew]
|
108
|
+
If you're on Mac OS X, you'll want to run the following with [Homebrew](http://www.brew.sh):
|
109
109
|
|
110
110
|
brew install imagemagick
|
111
111
|
|
@@ -167,7 +167,7 @@ Paperclip is distributed as a gem, which is how it should be used in your app.
|
|
167
167
|
Include the gem in your Gemfile:
|
168
168
|
|
169
169
|
```ruby
|
170
|
-
gem "paperclip", "~> 5.
|
170
|
+
gem "paperclip", "~> 5.2.1"
|
171
171
|
```
|
172
172
|
|
173
173
|
Or, if you want to get the latest, you can get master from the main paperclip repository:
|
@@ -206,6 +206,8 @@ end
|
|
206
206
|
|
207
207
|
### Migrations
|
208
208
|
|
209
|
+
|
210
|
+
Assuming you have a `users` table, add an `avatar` column to the `users` table:
|
209
211
|
```ruby
|
210
212
|
class AddAvatarColumnsToUsers < ActiveRecord::Migration
|
211
213
|
def up
|
@@ -221,10 +223,11 @@ end
|
|
221
223
|
(Or you can use the Rails migration generator: `rails generate paperclip user avatar`)
|
222
224
|
|
223
225
|
### Edit and New Views
|
224
|
-
|
226
|
+
Make sure you have corresponding methods in your controller:
|
225
227
|
```erb
|
226
228
|
<%= form_for @user, url: users_path, html: { multipart: true } do |form| %>
|
227
229
|
<%= form.file_field :avatar %>
|
230
|
+
<%= form.submit %>
|
228
231
|
<% end %>
|
229
232
|
```
|
230
233
|
|
@@ -233,6 +236,7 @@ end
|
|
233
236
|
```erb
|
234
237
|
<%= simple_form_for @user, url: users_path do |form| %>
|
235
238
|
<%= form.input :avatar, as: :file %>
|
239
|
+
<%= form.submit %>
|
236
240
|
<% end %>
|
237
241
|
```
|
238
242
|
|
@@ -240,7 +244,7 @@ end
|
|
240
244
|
|
241
245
|
```ruby
|
242
246
|
def create
|
243
|
-
@user = User.create(
|
247
|
+
@user = User.create(user_params)
|
244
248
|
end
|
245
249
|
|
246
250
|
private
|
@@ -254,7 +258,7 @@ end
|
|
254
258
|
```
|
255
259
|
|
256
260
|
### View Helpers
|
257
|
-
|
261
|
+
Add these to the view where you want your images displayed:
|
258
262
|
```erb
|
259
263
|
<%= image_tag @user.avatar.url %>
|
260
264
|
<%= image_tag @user.avatar.url(:medium) %>
|
@@ -347,7 +351,7 @@ called with valid attachments._
|
|
347
351
|
|
348
352
|
```ruby
|
349
353
|
class Message < ActiveRecord::Base
|
350
|
-
has_attached_file :asset, styles: {thumb: "100x100#"}
|
354
|
+
has_attached_file :asset, styles: { thumb: "100x100#" }
|
351
355
|
|
352
356
|
before_post_process :skip_for_audio
|
353
357
|
|
@@ -363,7 +367,7 @@ afterwards, then assign manually:
|
|
363
367
|
|
364
368
|
```ruby
|
365
369
|
class Book < ActiveRecord::Base
|
366
|
-
has_attached_file :document, styles: {thumbnail: "60x60#"}
|
370
|
+
has_attached_file :document, styles: { thumbnail: "60x60#" }
|
367
371
|
validates_attachment :document, content_type: { content_type: "application/pdf" }
|
368
372
|
validates_something_else # Other validations that conflict with Paperclip's
|
369
373
|
end
|
@@ -656,6 +660,14 @@ JPGs will remain JPGs). `Paperclip::Thumbnail` uses ImageMagick to process
|
|
656
660
|
images; [ImageMagick's geometry documentation](http://www.imagemagick.org/script/command-line-processing.php#geometry)
|
657
661
|
has more information on the accepted style formats.
|
658
662
|
|
663
|
+
For more fine-grained control of the conversion process, `source_file_options` and `convert_options` can be used to pass flags and settings directly to ImageMagick's powerful Convert tool, [documented here](https://www.imagemagick.org/script/convert.php). For example:
|
664
|
+
|
665
|
+
```ruby
|
666
|
+
has_attached_file :image, styles: { regular: ['800x800>', :png]},
|
667
|
+
source_file_options: { regular: "-density 96 -depth 8 -quality 85" },
|
668
|
+
convert_options: { regular: "-posterize 3"}
|
669
|
+
```
|
670
|
+
|
659
671
|
ImageMagick supports a number of environment variables for controlling its resource limits. For example, you can enforce memory or execution time limits by setting the following variables in your application's process environment:
|
660
672
|
|
661
673
|
* `MAGICK_MEMORY_LIMIT=128MiB`
|
@@ -738,7 +750,7 @@ called with valid attachments._
|
|
738
750
|
|
739
751
|
```ruby
|
740
752
|
class Message < ActiveRecord::Base
|
741
|
-
has_attached_file :asset, styles: {thumb: "100x100#"}
|
753
|
+
has_attached_file :asset, styles: { thumb: "100x100#" }
|
742
754
|
|
743
755
|
before_post_process :skip_for_audio
|
744
756
|
|
@@ -983,7 +995,7 @@ similar mechanism for whichever parallel testing library you use.
|
|
983
995
|
|
984
996
|
**Integration Tests**
|
985
997
|
|
986
|
-
Using integration tests with
|
998
|
+
Using integration tests with FactoryBot may save multiple copies of
|
987
999
|
your test files within the app. To avoid this, specify a custom path in
|
988
1000
|
the `config/environments/test.rb` like so:
|
989
1001
|
|
@@ -1000,11 +1012,11 @@ config.after(:suite) do
|
|
1000
1012
|
end
|
1001
1013
|
```
|
1002
1014
|
|
1003
|
-
**Example of test configuration with Factory
|
1015
|
+
**Example of test configuration with Factory Bot**
|
1004
1016
|
|
1005
1017
|
|
1006
1018
|
```ruby
|
1007
|
-
|
1019
|
+
FactoryBot.define do
|
1008
1020
|
factory :user do
|
1009
1021
|
avatar { File.new("#{Rails.root}/spec/support/fixtures/image.jpg") }
|
1010
1022
|
end
|
@@ -13,7 +13,9 @@ class PaperclipGenerator < ActiveRecord::Generators::Base
|
|
13
13
|
end
|
14
14
|
|
15
15
|
def generate_migration
|
16
|
-
migration_template
|
16
|
+
migration_template("paperclip_migration.rb.erb",
|
17
|
+
"db/migrate/#{migration_file_name}",
|
18
|
+
migration_version: migration_version)
|
17
19
|
end
|
18
20
|
|
19
21
|
def migration_name
|
@@ -27,4 +29,10 @@ class PaperclipGenerator < ActiveRecord::Generators::Base
|
|
27
29
|
def migration_class_name
|
28
30
|
migration_name.camelize
|
29
31
|
end
|
32
|
+
|
33
|
+
def migration_version
|
34
|
+
if Rails.version.start_with? "5"
|
35
|
+
"[#{Rails::VERSION::MAJOR}.#{Rails::VERSION::MINOR}]"
|
36
|
+
end
|
37
|
+
end
|
30
38
|
end
|
data/lib/paperclip.rb
CHANGED
@@ -16,7 +16,7 @@ module Paperclip
|
|
16
16
|
# On BSDs, `file` doesn't give a result code of 1 if the file doesn't exist.
|
17
17
|
type = begin
|
18
18
|
Paperclip.run("file", "-b --mime :file", file: @filename)
|
19
|
-
rescue
|
19
|
+
rescue Terrapin::CommandLineError => e
|
20
20
|
Paperclip.log("Error while determining content type: #{e}")
|
21
21
|
SENSIBLE_DEFAULT
|
22
22
|
end
|
@@ -24,9 +24,9 @@ module Paperclip
|
|
24
24
|
:swallow_stderr => true
|
25
25
|
}
|
26
26
|
)
|
27
|
-
rescue
|
27
|
+
rescue Terrapin::ExitStatusError
|
28
28
|
""
|
29
|
-
rescue
|
29
|
+
rescue Terrapin::CommandNotFoundError => e
|
30
30
|
raise_because_imagemagick_missing
|
31
31
|
end
|
32
32
|
end
|
data/lib/paperclip/helpers.rb
CHANGED
@@ -27,12 +27,12 @@ module Paperclip
|
|
27
27
|
#
|
28
28
|
def run(cmd, arguments = "", interpolation_values = {}, local_options = {})
|
29
29
|
command_path = options[:command_path]
|
30
|
-
|
31
|
-
|
30
|
+
terrapin_path_array = Terrapin::CommandLine.path.try(:split, Terrapin::OS.path_separator)
|
31
|
+
Terrapin::CommandLine.path = [terrapin_path_array, command_path].flatten.compact.uniq
|
32
32
|
if logging? && (options[:log_command] || local_options[:log_command])
|
33
33
|
local_options = local_options.merge(:logger => logger)
|
34
34
|
end
|
35
|
-
|
35
|
+
Terrapin::CommandLine.new(cmd, arguments, local_options).run(interpolation_values)
|
36
36
|
end
|
37
37
|
|
38
38
|
# Find all instances of the given Active Record model +klass+ with attachment +name+.
|
@@ -62,8 +62,12 @@ module Paperclip
|
|
62
62
|
@destination.close
|
63
63
|
@destination.open.binmode
|
64
64
|
rescue Errno::EXDEV, Errno::EPERM, Errno::ENOENT, Errno::EEXIST => e
|
65
|
-
Paperclip.log(
|
65
|
+
Paperclip.log(
|
66
|
+
"Link failed with #{e.message}; copying link #{src} to #{dest}"
|
67
|
+
)
|
66
68
|
FileUtils.cp(src, dest)
|
69
|
+
@destination.close
|
70
|
+
@destination.open.binmode
|
67
71
|
end
|
68
72
|
end
|
69
73
|
end
|
@@ -72,8 +72,9 @@ module Paperclip
|
|
72
72
|
|
73
73
|
def type_from_file_command
|
74
74
|
begin
|
75
|
-
Paperclip.run("file", "-b --mime :file", :
|
76
|
-
|
75
|
+
Paperclip.run("file", "-b --mime :file", file: @file.path).
|
76
|
+
split(/[:;\s]+/).first
|
77
|
+
rescue Terrapin::CommandLineError
|
77
78
|
""
|
78
79
|
end
|
79
80
|
end
|
@@ -117,6 +117,7 @@ module Paperclip
|
|
117
117
|
raise if retried
|
118
118
|
retried = true
|
119
119
|
directory.save
|
120
|
+
file.rewind
|
120
121
|
retry
|
121
122
|
ensure
|
122
123
|
file.rewind
|
@@ -184,7 +185,7 @@ module Paperclip
|
|
184
185
|
private
|
185
186
|
|
186
187
|
def convert_time(time)
|
187
|
-
if time.is_a?(
|
188
|
+
if time.is_a?(Integer)
|
188
189
|
time = Time.now + time
|
189
190
|
end
|
190
191
|
time
|
data/lib/paperclip/storage/s3.rb
CHANGED
@@ -94,7 +94,8 @@ module Paperclip
|
|
94
94
|
# to interpolate. Keys should be unique, like filenames, and despite the fact that
|
95
95
|
# S3 (strictly speaking) does not support directories, you can still use a / to
|
96
96
|
# separate parts of your file name.
|
97
|
-
# * +s3_host_name+: If you are using your bucket in Tokyo region
|
97
|
+
# * +s3_host_name+: If you are using your bucket in Tokyo region
|
98
|
+
# etc, write host_name (e.g., 's3-ap-northeast-1.amazonaws.com').
|
98
99
|
# * +s3_region+: For aws-sdk v2, s3_region is required.
|
99
100
|
# * +s3_metadata+: These key/value pairs will be stored with the
|
100
101
|
# object. This option works by prefixing each key with
|
data/lib/paperclip/thumbnail.rb
CHANGED
@@ -84,9 +84,9 @@ module Paperclip
|
|
84
84
|
source: "#{File.expand_path(src.path)}#{frame}",
|
85
85
|
dest: File.expand_path(dst.path),
|
86
86
|
)
|
87
|
-
rescue
|
87
|
+
rescue Terrapin::ExitStatusError => e
|
88
88
|
raise Paperclip::Error, "There was an error processing the thumbnail for #{@basename}" if @whiny
|
89
|
-
rescue
|
89
|
+
rescue Terrapin::CommandNotFoundError => e
|
90
90
|
raise Paperclip::Errors::CommandNotFoundError.new("Could not run the `convert` command. Please install ImageMagick.")
|
91
91
|
end
|
92
92
|
|
@@ -122,9 +122,9 @@ module Paperclip
|
|
122
122
|
@identified_as_animated = ANIMATED_FORMATS.include? identify("-format %m :file", :file => "#{@file.path}[0]").to_s.downcase.strip
|
123
123
|
end
|
124
124
|
@identified_as_animated
|
125
|
-
rescue
|
125
|
+
rescue Terrapin::ExitStatusError => e
|
126
126
|
raise Paperclip::Error, "There was an error running `identify` for #{@basename}" if @whiny
|
127
|
-
rescue
|
127
|
+
rescue Terrapin::CommandNotFoundError => e
|
128
128
|
raise Paperclip::Errors::CommandNotFoundError.new("Could not run the `identify` command. Please install ImageMagick.")
|
129
129
|
end
|
130
130
|
end
|
data/lib/paperclip/version.rb
CHANGED
data/paperclip.gemspec
CHANGED
@@ -26,7 +26,7 @@ Gem::Specification.new do |s|
|
|
26
26
|
|
27
27
|
s.add_dependency('activemodel', '>= 4.2.0')
|
28
28
|
s.add_dependency('activesupport', '>= 4.2.0')
|
29
|
-
s.add_dependency('
|
29
|
+
s.add_dependency('terrapin', '~> 0.6.0')
|
30
30
|
s.add_dependency('mime-types')
|
31
31
|
s.add_dependency('mimemagic', '~> 0.3.0')
|
32
32
|
|
@@ -41,7 +41,7 @@ describe Paperclip::ContentTypeDetector do
|
|
41
41
|
end
|
42
42
|
|
43
43
|
it 'returns a sensible default when the file command is missing' do
|
44
|
-
Paperclip.stubs(:run).raises(
|
44
|
+
Paperclip.stubs(:run).raises(Terrapin::CommandLineError.new)
|
45
45
|
@filename = "/path/to/something"
|
46
46
|
assert_equal "application/octet-stream", Paperclip::ContentTypeDetector.new(@filename).detect
|
47
47
|
end
|
@@ -12,7 +12,7 @@ describe Paperclip::FileCommandContentTypeDetector do
|
|
12
12
|
end
|
13
13
|
|
14
14
|
it 'returns a sensible default when the file command is missing' do
|
15
|
-
Paperclip.stubs(:run).raises(
|
15
|
+
Paperclip.stubs(:run).raises(Terrapin::CommandLineError.new)
|
16
16
|
@filename = "/path/to/something"
|
17
17
|
assert_equal "application/octet-stream",
|
18
18
|
Paperclip::FileCommandContentTypeDetector.new(@filename).detect
|
@@ -23,4 +23,18 @@ describe Paperclip::FileCommandContentTypeDetector do
|
|
23
23
|
assert_equal "application/octet-stream",
|
24
24
|
Paperclip::FileCommandContentTypeDetector.new("windows").detect
|
25
25
|
end
|
26
|
+
|
27
|
+
context "#type_from_file_command" do
|
28
|
+
let(:detector) { Paperclip::FileCommandContentTypeDetector.new("html") }
|
29
|
+
|
30
|
+
it "does work with the output of old versions of file" do
|
31
|
+
Paperclip.stubs(:run).returns("text/html charset=us-ascii")
|
32
|
+
expect(detector.detect).to eq("text/html")
|
33
|
+
end
|
34
|
+
|
35
|
+
it "does work with the output of new versions of file" do
|
36
|
+
Paperclip.stubs(:run).returns("text/html; charset=us-ascii")
|
37
|
+
expect(detector.detect).to eq("text/html")
|
38
|
+
end
|
39
|
+
end
|
26
40
|
end
|
@@ -98,4 +98,35 @@ describe Paperclip::AbstractAdapter do
|
|
98
98
|
expect { subject.original_filename = nil }.not_to raise_error
|
99
99
|
end
|
100
100
|
end
|
101
|
+
|
102
|
+
context "#link_or_copy_file" do
|
103
|
+
class TestLinkOrCopyAdapter < Paperclip::AbstractAdapter
|
104
|
+
public :copy_to_tempfile, :destination
|
105
|
+
end
|
106
|
+
|
107
|
+
subject { TestLinkOrCopyAdapter.new(nil) }
|
108
|
+
let(:body) { "body" }
|
109
|
+
|
110
|
+
let(:file) do
|
111
|
+
t = Tempfile.new("destination")
|
112
|
+
t.print(body)
|
113
|
+
t.rewind
|
114
|
+
t
|
115
|
+
end
|
116
|
+
|
117
|
+
after do
|
118
|
+
file.close
|
119
|
+
file.unlink
|
120
|
+
end
|
121
|
+
|
122
|
+
it "should be able to read the file" do
|
123
|
+
expect(subject.copy_to_tempfile(file).read).to eq(body)
|
124
|
+
end
|
125
|
+
|
126
|
+
it "should be able to reopen the file after symlink has failed" do
|
127
|
+
FileUtils.expects(:ln).raises(Errno::EXDEV)
|
128
|
+
|
129
|
+
expect(subject.copy_to_tempfile(file).read).to eq(body)
|
130
|
+
end
|
131
|
+
end
|
101
132
|
end
|
@@ -76,4 +76,19 @@ describe Paperclip::MediaTypeSpoofDetector do
|
|
76
76
|
Paperclip.options[:content_type_mappings] = {}
|
77
77
|
end
|
78
78
|
end
|
79
|
+
|
80
|
+
context "#type_from_file_command" do
|
81
|
+
let(:file) { File.new(fixture_file("empty.html")) }
|
82
|
+
let(:detector) { Paperclip::MediaTypeSpoofDetector.new(file, "html", "") }
|
83
|
+
|
84
|
+
it "does work with the output of old versions of file" do
|
85
|
+
Paperclip.stubs(:run).returns("text/html charset=us-ascii")
|
86
|
+
expect(detector.send(:type_from_file_command)).to eq("text/html")
|
87
|
+
end
|
88
|
+
|
89
|
+
it "does work with the output of new versions of file" do
|
90
|
+
Paperclip.stubs(:run).returns("text/html; charset=us-ascii")
|
91
|
+
expect(detector.send(:type_from_file_command)).to eq("text/html")
|
92
|
+
end
|
93
|
+
end
|
79
94
|
end
|
@@ -4,40 +4,40 @@ describe Paperclip do
|
|
4
4
|
context ".run" do
|
5
5
|
before do
|
6
6
|
Paperclip.options[:log_command] = false
|
7
|
-
|
8
|
-
@original_command_line_path =
|
7
|
+
Terrapin::CommandLine.expects(:new).with("convert", "stuff", {}).returns(stub(:run))
|
8
|
+
@original_command_line_path = Terrapin::CommandLine.path
|
9
9
|
end
|
10
10
|
|
11
11
|
after do
|
12
12
|
Paperclip.options[:log_command] = true
|
13
|
-
|
13
|
+
Terrapin::CommandLine.path = @original_command_line_path
|
14
14
|
end
|
15
15
|
|
16
|
-
it "runs the command with
|
16
|
+
it "runs the command with Terrapin" do
|
17
17
|
Paperclip.run("convert", "stuff")
|
18
18
|
end
|
19
19
|
|
20
|
-
it "saves
|
21
|
-
|
20
|
+
it "saves Terrapin::CommandLine.path that set before" do
|
21
|
+
Terrapin::CommandLine.path = "/opt/my_app/bin"
|
22
22
|
Paperclip.run("convert", "stuff")
|
23
|
-
expect(
|
23
|
+
expect(Terrapin::CommandLine.path).to match("/opt/my_app/bin")
|
24
24
|
end
|
25
25
|
|
26
|
-
it "does not duplicate
|
27
|
-
|
28
|
-
|
26
|
+
it "does not duplicate Terrapin::CommandLine.path on multiple runs" do
|
27
|
+
Terrapin::CommandLine.expects(:new).with("convert", "more_stuff", {}).returns(stub(:run))
|
28
|
+
Terrapin::CommandLine.path = nil
|
29
29
|
Paperclip.options[:command_path] = "/opt/my_app/bin"
|
30
30
|
Paperclip.run("convert", "stuff")
|
31
31
|
Paperclip.run("convert", "more_stuff")
|
32
32
|
|
33
33
|
cmd_path = Paperclip.options[:command_path]
|
34
|
-
assert_equal 1,
|
34
|
+
assert_equal 1, Terrapin::CommandLine.path.scan(cmd_path).count
|
35
35
|
end
|
36
36
|
end
|
37
37
|
|
38
38
|
it 'does not raise errors when doing a lot of running' do
|
39
39
|
Paperclip.options[:command_path] = ["/usr/local/bin"] * 1024
|
40
|
-
|
40
|
+
Terrapin::CommandLine.path = "/something/else"
|
41
41
|
100.times do |x|
|
42
42
|
Paperclip.run("echo", x.to_s)
|
43
43
|
end
|
@@ -63,7 +63,7 @@ describe Paperclip do
|
|
63
63
|
context "Calling Paperclip.run with a logger" do
|
64
64
|
it "passes the defined logger if :log_command is set" do
|
65
65
|
Paperclip.options[:log_command] = true
|
66
|
-
|
66
|
+
Terrapin::CommandLine.expects(:new).with("convert", "stuff", logger: Paperclip.logger).returns(stub(:run))
|
67
67
|
Paperclip.run("convert", "stuff")
|
68
68
|
end
|
69
69
|
end
|
@@ -9,17 +9,17 @@ describe Paperclip::Processor do
|
|
9
9
|
end
|
10
10
|
|
11
11
|
context "Calling #convert" do
|
12
|
-
it "runs the convert command with
|
12
|
+
it "runs the convert command with Terrapin" do
|
13
13
|
Paperclip.options[:log_command] = false
|
14
|
-
|
14
|
+
Terrapin::CommandLine.expects(:new).with("convert", "stuff", {}).returns(stub(:run))
|
15
15
|
Paperclip::Processor.new('filename').convert("stuff")
|
16
16
|
end
|
17
17
|
end
|
18
18
|
|
19
19
|
context "Calling #identify" do
|
20
|
-
it "runs the identify command with
|
20
|
+
it "runs the identify command with Terrapin" do
|
21
21
|
Paperclip.options[:log_command] = false
|
22
|
-
|
22
|
+
Terrapin::CommandLine.expects(:new).with("identify", "stuff", {}).returns(stub(:run))
|
23
23
|
Paperclip::Processor.new('filename').identify("stuff")
|
24
24
|
end
|
25
25
|
end
|
@@ -206,6 +206,11 @@ describe Paperclip::Storage::Fog do
|
|
206
206
|
assert @dummy.save
|
207
207
|
assert @connection.directories.get(@fog_directory)
|
208
208
|
end
|
209
|
+
|
210
|
+
it "sucessfully rewinds the file during bucket creation" do
|
211
|
+
assert @dummy.save
|
212
|
+
expect(Paperclip.io_adapters.for(@dummy.avatar).read.length).to be > 0
|
213
|
+
end
|
209
214
|
end
|
210
215
|
|
211
216
|
context "with a bucket" do
|
@@ -48,7 +48,7 @@ describe Paperclip::Thumbnail do
|
|
48
48
|
it "lets us know when a command isn't found versus a processing error" do
|
49
49
|
old_path = ENV['PATH']
|
50
50
|
begin
|
51
|
-
|
51
|
+
Terrapin::CommandLine.path = ''
|
52
52
|
Paperclip.options[:command_path] = ''
|
53
53
|
ENV['PATH'] = ''
|
54
54
|
assert_raises(Paperclip::Errors::CommandNotFoundError) do
|
@@ -102,7 +102,7 @@ describe Paperclip::Thumbnail do
|
|
102
102
|
|
103
103
|
output_file = thumb.make
|
104
104
|
|
105
|
-
command =
|
105
|
+
command = Terrapin::CommandLine.new("identify", "-format %wx%h :file")
|
106
106
|
assert_equal "50x50", command.run(file: output_file.path).strip
|
107
107
|
end
|
108
108
|
|
@@ -189,7 +189,7 @@ describe Paperclip::Thumbnail do
|
|
189
189
|
it "lets us know when a command isn't found versus a processing error" do
|
190
190
|
old_path = ENV['PATH']
|
191
191
|
begin
|
192
|
-
|
192
|
+
Terrapin::CommandLine.path = ''
|
193
193
|
Paperclip.options[:command_path] = ''
|
194
194
|
ENV['PATH'] = ''
|
195
195
|
assert_raises(Paperclip::Errors::CommandNotFoundError) do
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: paperclip
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 5.
|
4
|
+
version: 5.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jon Yurek
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-03-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activemodel
|
@@ -39,19 +39,19 @@ dependencies:
|
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: 4.2.0
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
|
-
name:
|
42
|
+
name: terrapin
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
45
|
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: 0.
|
47
|
+
version: 0.6.0
|
48
48
|
type: :runtime
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: 0.
|
54
|
+
version: 0.6.0
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: mime-types
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -611,8 +611,113 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
611
611
|
requirements:
|
612
612
|
- ImageMagick
|
613
613
|
rubyforge_project:
|
614
|
-
rubygems_version: 2.6.
|
614
|
+
rubygems_version: 2.6.11
|
615
615
|
signing_key:
|
616
616
|
specification_version: 4
|
617
617
|
summary: File attachments as attributes for ActiveRecord
|
618
|
-
test_files:
|
618
|
+
test_files:
|
619
|
+
- features/basic_integration.feature
|
620
|
+
- features/migration.feature
|
621
|
+
- features/rake_tasks.feature
|
622
|
+
- features/step_definitions/attachment_steps.rb
|
623
|
+
- features/step_definitions/html_steps.rb
|
624
|
+
- features/step_definitions/rails_steps.rb
|
625
|
+
- features/step_definitions/s3_steps.rb
|
626
|
+
- features/step_definitions/web_steps.rb
|
627
|
+
- features/support/env.rb
|
628
|
+
- features/support/fakeweb.rb
|
629
|
+
- features/support/file_helpers.rb
|
630
|
+
- features/support/fixtures/boot_config.txt
|
631
|
+
- features/support/fixtures/gemfile.txt
|
632
|
+
- features/support/fixtures/preinitializer.txt
|
633
|
+
- features/support/paths.rb
|
634
|
+
- features/support/rails.rb
|
635
|
+
- features/support/selectors.rb
|
636
|
+
- spec/database.yml
|
637
|
+
- spec/paperclip/attachment_definitions_spec.rb
|
638
|
+
- spec/paperclip/attachment_processing_spec.rb
|
639
|
+
- spec/paperclip/attachment_registry_spec.rb
|
640
|
+
- spec/paperclip/attachment_spec.rb
|
641
|
+
- spec/paperclip/content_type_detector_spec.rb
|
642
|
+
- spec/paperclip/file_command_content_type_detector_spec.rb
|
643
|
+
- spec/paperclip/filename_cleaner_spec.rb
|
644
|
+
- spec/paperclip/geometry_detector_spec.rb
|
645
|
+
- spec/paperclip/geometry_parser_spec.rb
|
646
|
+
- spec/paperclip/geometry_spec.rb
|
647
|
+
- spec/paperclip/glue_spec.rb
|
648
|
+
- spec/paperclip/has_attached_file_spec.rb
|
649
|
+
- spec/paperclip/integration_spec.rb
|
650
|
+
- spec/paperclip/interpolations_spec.rb
|
651
|
+
- spec/paperclip/io_adapters/abstract_adapter_spec.rb
|
652
|
+
- spec/paperclip/io_adapters/attachment_adapter_spec.rb
|
653
|
+
- spec/paperclip/io_adapters/data_uri_adapter_spec.rb
|
654
|
+
- spec/paperclip/io_adapters/empty_string_adapter_spec.rb
|
655
|
+
- spec/paperclip/io_adapters/file_adapter_spec.rb
|
656
|
+
- spec/paperclip/io_adapters/http_url_proxy_adapter_spec.rb
|
657
|
+
- spec/paperclip/io_adapters/identity_adapter_spec.rb
|
658
|
+
- spec/paperclip/io_adapters/nil_adapter_spec.rb
|
659
|
+
- spec/paperclip/io_adapters/registry_spec.rb
|
660
|
+
- spec/paperclip/io_adapters/stringio_adapter_spec.rb
|
661
|
+
- spec/paperclip/io_adapters/uploaded_file_adapter_spec.rb
|
662
|
+
- spec/paperclip/io_adapters/uri_adapter_spec.rb
|
663
|
+
- spec/paperclip/matchers/have_attached_file_matcher_spec.rb
|
664
|
+
- spec/paperclip/matchers/validate_attachment_content_type_matcher_spec.rb
|
665
|
+
- spec/paperclip/matchers/validate_attachment_presence_matcher_spec.rb
|
666
|
+
- spec/paperclip/matchers/validate_attachment_size_matcher_spec.rb
|
667
|
+
- spec/paperclip/media_type_spoof_detector_spec.rb
|
668
|
+
- spec/paperclip/meta_class_spec.rb
|
669
|
+
- spec/paperclip/paperclip_missing_attachment_styles_spec.rb
|
670
|
+
- spec/paperclip/paperclip_spec.rb
|
671
|
+
- spec/paperclip/plural_cache_spec.rb
|
672
|
+
- spec/paperclip/processor_helpers_spec.rb
|
673
|
+
- spec/paperclip/processor_spec.rb
|
674
|
+
- spec/paperclip/rails_environment_spec.rb
|
675
|
+
- spec/paperclip/rake_spec.rb
|
676
|
+
- spec/paperclip/schema_spec.rb
|
677
|
+
- spec/paperclip/storage/filesystem_spec.rb
|
678
|
+
- spec/paperclip/storage/fog_spec.rb
|
679
|
+
- spec/paperclip/storage/s3_live_spec.rb
|
680
|
+
- spec/paperclip/storage/s3_spec.rb
|
681
|
+
- spec/paperclip/style_spec.rb
|
682
|
+
- spec/paperclip/tempfile_factory_spec.rb
|
683
|
+
- spec/paperclip/tempfile_spec.rb
|
684
|
+
- spec/paperclip/thumbnail_spec.rb
|
685
|
+
- spec/paperclip/url_generator_spec.rb
|
686
|
+
- spec/paperclip/validators/attachment_content_type_validator_spec.rb
|
687
|
+
- spec/paperclip/validators/attachment_file_name_validator_spec.rb
|
688
|
+
- spec/paperclip/validators/attachment_presence_validator_spec.rb
|
689
|
+
- spec/paperclip/validators/attachment_size_validator_spec.rb
|
690
|
+
- spec/paperclip/validators/media_type_spoof_detection_validator_spec.rb
|
691
|
+
- spec/paperclip/validators_spec.rb
|
692
|
+
- spec/spec_helper.rb
|
693
|
+
- spec/support/assertions.rb
|
694
|
+
- spec/support/conditional_filter_helper.rb
|
695
|
+
- spec/support/fake_model.rb
|
696
|
+
- spec/support/fake_rails.rb
|
697
|
+
- spec/support/fixtures/12k.png
|
698
|
+
- spec/support/fixtures/50x50.png
|
699
|
+
- spec/support/fixtures/5k.png
|
700
|
+
- spec/support/fixtures/animated
|
701
|
+
- spec/support/fixtures/animated.gif
|
702
|
+
- spec/support/fixtures/animated.unknown
|
703
|
+
- spec/support/fixtures/bad.png
|
704
|
+
- spec/support/fixtures/empty.html
|
705
|
+
- spec/support/fixtures/empty.xlsx
|
706
|
+
- spec/support/fixtures/fog.yml
|
707
|
+
- spec/support/fixtures/rotated.jpg
|
708
|
+
- spec/support/fixtures/s3.yml
|
709
|
+
- spec/support/fixtures/spaced file.jpg
|
710
|
+
- spec/support/fixtures/spaced file.png
|
711
|
+
- spec/support/fixtures/text.txt
|
712
|
+
- spec/support/fixtures/twopage.pdf
|
713
|
+
- spec/support/fixtures/uppercase.PNG
|
714
|
+
- spec/support/matchers/accept.rb
|
715
|
+
- spec/support/matchers/exist.rb
|
716
|
+
- spec/support/matchers/have_column.rb
|
717
|
+
- spec/support/mock_attachment.rb
|
718
|
+
- spec/support/mock_interpolator.rb
|
719
|
+
- spec/support/mock_url_generator_builder.rb
|
720
|
+
- spec/support/model_reconstruction.rb
|
721
|
+
- spec/support/reporting.rb
|
722
|
+
- spec/support/test_data.rb
|
723
|
+
- spec/support/version_helper.rb
|