kt-paperclip 7.2.2 → 8.0.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/LICENSE +1 -1
- data/README.md +24 -56
- data/lib/generators/paperclip/paperclip_generator.rb +3 -1
- data/lib/kt-paperclip.rb +2 -0
- data/lib/paperclip/attachment.rb +49 -30
- data/lib/paperclip/attachment_registry.rb +2 -0
- data/lib/paperclip/callbacks.rb +7 -4
- data/lib/paperclip/commands/imagemagick/geometry_parser.rb +63 -0
- data/lib/paperclip/commands/imagemagick/version_detector.rb +41 -0
- data/lib/paperclip/commands/imagemagick.rb +44 -0
- data/lib/paperclip/commands/runner.rb +38 -0
- data/lib/paperclip/commands/unix_file.rb +28 -0
- data/lib/paperclip/content_type_detector.rb +31 -32
- data/lib/paperclip/errors.rb +2 -0
- data/lib/paperclip/file_command_content_type_detector.rb +11 -12
- data/lib/paperclip/filename_cleaner.rb +2 -0
- data/lib/paperclip/geometry.rb +22 -7
- data/lib/paperclip/geometry_detector_factory.rb +11 -31
- data/lib/paperclip/geometry_parser_factory.rb +13 -17
- data/lib/paperclip/glue.rb +2 -0
- data/lib/paperclip/has_attached_file.rb +2 -0
- data/lib/paperclip/helpers.rb +5 -25
- data/lib/paperclip/interpolations/plural_cache.rb +2 -0
- data/lib/paperclip/interpolations.rb +2 -0
- data/lib/paperclip/io_adapters/abstract_adapter.rb +3 -1
- data/lib/paperclip/io_adapters/attachment_adapter.rb +11 -0
- data/lib/paperclip/io_adapters/data_uri_adapter.rb +2 -0
- data/lib/paperclip/io_adapters/empty_string_adapter.rb +2 -0
- data/lib/paperclip/io_adapters/file_adapter.rb +2 -0
- data/lib/paperclip/io_adapters/http_url_proxy_adapter.rb +2 -0
- data/lib/paperclip/io_adapters/identity_adapter.rb +2 -0
- data/lib/paperclip/io_adapters/nil_adapter.rb +2 -0
- data/lib/paperclip/io_adapters/registry.rb +2 -0
- data/lib/paperclip/io_adapters/stringio_adapter.rb +2 -0
- data/lib/paperclip/io_adapters/uploaded_file_adapter.rb +2 -0
- data/lib/paperclip/io_adapters/uri_adapter.rb +5 -13
- data/lib/paperclip/locales/fr.yml +18 -0
- data/lib/paperclip/locales/gd.yml +1 -1
- data/lib/paperclip/logger.rb +2 -0
- data/lib/paperclip/matchers/have_attached_file_matcher.rb +2 -0
- data/lib/paperclip/matchers/validate_attachment_content_type_matcher.rb +5 -3
- data/lib/paperclip/matchers/validate_attachment_presence_matcher.rb +2 -0
- data/lib/paperclip/matchers/validate_attachment_size_matcher.rb +2 -0
- data/lib/paperclip/matchers.rb +2 -0
- data/lib/paperclip/media_type_spoof_detector.rb +3 -10
- data/lib/paperclip/missing_attachment_styles.rb +2 -0
- data/lib/paperclip/processor.rb +6 -19
- data/lib/paperclip/processor_helpers.rb +2 -0
- data/lib/paperclip/rails_environment.rb +2 -0
- data/lib/paperclip/railtie.rb +2 -0
- data/lib/paperclip/schema.rb +6 -4
- data/lib/paperclip/storage/filesystem.rb +2 -0
- data/lib/paperclip/storage/fog.rb +13 -4
- data/lib/paperclip/storage/s3.rb +27 -5
- data/lib/paperclip/storage.rb +2 -0
- data/lib/paperclip/style.rb +2 -0
- data/lib/paperclip/tempfile.rb +2 -0
- data/lib/paperclip/tempfile_factory.rb +2 -0
- data/lib/paperclip/thumbnail.rb +9 -10
- data/lib/paperclip/url_generator.rb +2 -0
- data/lib/paperclip/validators/attachment_content_type_validator.rb +2 -0
- data/lib/paperclip/validators/attachment_file_name_validator.rb +2 -0
- data/lib/paperclip/validators/attachment_file_type_ignorance_validator.rb +2 -0
- data/lib/paperclip/validators/attachment_presence_validator.rb +2 -0
- data/lib/paperclip/validators/attachment_size_validator.rb +2 -0
- data/lib/paperclip/validators/media_type_spoof_detection_validator.rb +2 -0
- data/lib/paperclip/validators.rb +2 -0
- data/lib/paperclip/version.rb +3 -1
- data/lib/paperclip.rb +25 -4
- data/lib/tasks/paperclip.rake +9 -4
- data/shoulda_macros/paperclip.rb +2 -0
- metadata +19 -538
- data/.codeclimate.yml +0 -17
- data/.github/FUNDING.yml +0 -3
- data/.github/ISSUE_TEMPLATE/bug_report.md +0 -38
- data/.github/ISSUE_TEMPLATE/custom.md +0 -10
- data/.github/ISSUE_TEMPLATE/feature_request.md +0 -20
- data/.gitignore +0 -19
- data/.hound.yml +0 -3
- data/.rubocop.yml +0 -1061
- data/.travis.yml +0 -45
- data/Appraisals +0 -30
- data/CONTRIBUTING.md +0 -85
- data/Gemfile +0 -19
- data/NEWS +0 -554
- data/RELEASING.md +0 -17
- data/Rakefile +0 -52
- data/UPGRADING +0 -17
- data/features/basic_integration.feature +0 -85
- data/features/migration.feature +0 -29
- data/features/rake_tasks.feature +0 -62
- data/features/step_definitions/attachment_steps.rb +0 -120
- data/features/step_definitions/html_steps.rb +0 -15
- data/features/step_definitions/rails_steps.rb +0 -257
- data/features/step_definitions/s3_steps.rb +0 -14
- data/features/step_definitions/web_steps.rb +0 -106
- data/features/support/env.rb +0 -12
- data/features/support/fakeweb.rb +0 -11
- data/features/support/file_helpers.rb +0 -34
- data/features/support/fixtures/boot_config.txt +0 -15
- data/features/support/fixtures/gemfile.txt +0 -5
- data/features/support/fixtures/preinitializer.txt +0 -20
- data/features/support/paths.rb +0 -28
- data/features/support/rails.rb +0 -39
- data/features/support/selectors.rb +0 -19
- data/gemfiles/4.2.gemfile +0 -20
- data/gemfiles/5.0.gemfile +0 -20
- data/gemfiles/5.1.gemfile +0 -20
- data/gemfiles/5.2.gemfile +0 -20
- data/gemfiles/6.0.gemfile +0 -20
- data/gemfiles/6.1.gemfile +0 -21
- data/gemfiles/7.0.gemfile +0 -21
- data/paperclip.gemspec +0 -50
- data/spec/database.yml +0 -4
- data/spec/paperclip/attachment_definitions_spec.rb +0 -13
- data/spec/paperclip/attachment_processing_spec.rb +0 -79
- data/spec/paperclip/attachment_registry_spec.rb +0 -158
- data/spec/paperclip/attachment_spec.rb +0 -1590
- data/spec/paperclip/content_type_detector_spec.rb +0 -54
- data/spec/paperclip/file_command_content_type_detector_spec.rb +0 -40
- data/spec/paperclip/filename_cleaner_spec.rb +0 -13
- data/spec/paperclip/geometry_detector_spec.rb +0 -47
- data/spec/paperclip/geometry_parser_spec.rb +0 -73
- data/spec/paperclip/geometry_spec.rb +0 -267
- data/spec/paperclip/glue_spec.rb +0 -63
- data/spec/paperclip/has_attached_file_spec.rb +0 -78
- data/spec/paperclip/integration_spec.rb +0 -702
- data/spec/paperclip/interpolations_spec.rb +0 -270
- data/spec/paperclip/io_adapters/abstract_adapter_spec.rb +0 -160
- data/spec/paperclip/io_adapters/attachment_adapter_spec.rb +0 -140
- data/spec/paperclip/io_adapters/data_uri_adapter_spec.rb +0 -88
- data/spec/paperclip/io_adapters/empty_string_adapter_spec.rb +0 -17
- data/spec/paperclip/io_adapters/file_adapter_spec.rb +0 -131
- data/spec/paperclip/io_adapters/http_url_proxy_adapter_spec.rb +0 -142
- data/spec/paperclip/io_adapters/identity_adapter_spec.rb +0 -8
- data/spec/paperclip/io_adapters/nil_adapter_spec.rb +0 -25
- data/spec/paperclip/io_adapters/registry_spec.rb +0 -35
- data/spec/paperclip/io_adapters/stringio_adapter_spec.rb +0 -64
- data/spec/paperclip/io_adapters/uploaded_file_adapter_spec.rb +0 -146
- data/spec/paperclip/io_adapters/uri_adapter_spec.rb +0 -231
- data/spec/paperclip/matchers/have_attached_file_matcher_spec.rb +0 -19
- data/spec/paperclip/matchers/validate_attachment_content_type_matcher_spec.rb +0 -108
- data/spec/paperclip/matchers/validate_attachment_presence_matcher_spec.rb +0 -69
- data/spec/paperclip/matchers/validate_attachment_size_matcher_spec.rb +0 -88
- data/spec/paperclip/media_type_spoof_detector_spec.rb +0 -126
- data/spec/paperclip/meta_class_spec.rb +0 -30
- data/spec/paperclip/paperclip_missing_attachment_styles_spec.rb +0 -88
- data/spec/paperclip/paperclip_spec.rb +0 -196
- data/spec/paperclip/plural_cache_spec.rb +0 -37
- data/spec/paperclip/processor_helpers_spec.rb +0 -57
- data/spec/paperclip/processor_spec.rb +0 -26
- data/spec/paperclip/rails_environment_spec.rb +0 -30
- data/spec/paperclip/rake_spec.rb +0 -103
- data/spec/paperclip/schema_spec.rb +0 -252
- data/spec/paperclip/storage/filesystem_spec.rb +0 -102
- data/spec/paperclip/storage/fog_spec.rb +0 -606
- data/spec/paperclip/storage/s3_live_spec.rb +0 -188
- data/spec/paperclip/storage/s3_spec.rb +0 -1878
- data/spec/paperclip/style_spec.rb +0 -251
- data/spec/paperclip/tempfile_factory_spec.rb +0 -33
- data/spec/paperclip/tempfile_spec.rb +0 -35
- data/spec/paperclip/thumbnail_spec.rb +0 -504
- data/spec/paperclip/url_generator_spec.rb +0 -231
- data/spec/paperclip/validators/attachment_content_type_validator_spec.rb +0 -410
- data/spec/paperclip/validators/attachment_file_name_validator_spec.rb +0 -249
- data/spec/paperclip/validators/attachment_presence_validator_spec.rb +0 -85
- data/spec/paperclip/validators/attachment_size_validator_spec.rb +0 -325
- data/spec/paperclip/validators/media_type_spoof_detection_validator_spec.rb +0 -48
- data/spec/paperclip/validators_spec.rb +0 -179
- data/spec/spec_helper.rb +0 -46
- data/spec/support/assertions.rb +0 -84
- data/spec/support/fake_model.rb +0 -24
- data/spec/support/fake_rails.rb +0 -12
- data/spec/support/fixtures/12k.png +0 -0
- data/spec/support/fixtures/50x50.png +0 -0
- data/spec/support/fixtures/5k.png +0 -0
- data/spec/support/fixtures/animated +0 -0
- data/spec/support/fixtures/animated.gif +0 -0
- data/spec/support/fixtures/animated.unknown +0 -0
- data/spec/support/fixtures/aws_s3.yml +0 -13
- data/spec/support/fixtures/bad.png +0 -1
- data/spec/support/fixtures/empty.html +0 -1
- data/spec/support/fixtures/empty.xlsx +0 -0
- data/spec/support/fixtures/fog.yml +0 -8
- data/spec/support/fixtures/rotated.jpg +0 -0
- data/spec/support/fixtures/s3.yml +0 -8
- data/spec/support/fixtures/sample.xlsm +0 -0
- data/spec/support/fixtures/spaced file.jpg +0 -0
- data/spec/support/fixtures/spaced file.png +0 -0
- data/spec/support/fixtures/text.txt +0 -1
- data/spec/support/fixtures/twopage.pdf +0 -0
- data/spec/support/fixtures/uppercase.PNG +0 -0
- data/spec/support/matchers/accept.rb +0 -5
- data/spec/support/matchers/exist.rb +0 -5
- data/spec/support/matchers/have_column.rb +0 -23
- data/spec/support/mock_attachment.rb +0 -24
- data/spec/support/mock_interpolator.rb +0 -24
- data/spec/support/mock_url_generator_builder.rb +0 -26
- data/spec/support/model_reconstruction.rb +0 -72
- data/spec/support/reporting.rb +0 -11
- data/spec/support/test_data.rb +0 -13
- data/spec/support/version_helper.rb +0 -9
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
module Paperclip
|
|
2
4
|
module Storage
|
|
3
5
|
# fog is a modern and versatile cloud computing library for Ruby.
|
|
@@ -44,8 +46,7 @@ module Paperclip
|
|
|
44
46
|
begin
|
|
45
47
|
require "fog"
|
|
46
48
|
rescue LoadError => e
|
|
47
|
-
e.message
|
|
48
|
-
raise e
|
|
49
|
+
raise("#{e.message} (You may need to install the fog gem)")
|
|
49
50
|
end
|
|
50
51
|
end
|
|
51
52
|
|
|
@@ -214,9 +215,9 @@ module Paperclip
|
|
|
214
215
|
def find_credentials(creds)
|
|
215
216
|
case creds
|
|
216
217
|
when File
|
|
217
|
-
|
|
218
|
+
load_credentials_from_file(creds.path)
|
|
218
219
|
when String, Pathname
|
|
219
|
-
|
|
220
|
+
load_credentials_from_file(creds)
|
|
220
221
|
when Hash
|
|
221
222
|
creds
|
|
222
223
|
else
|
|
@@ -228,6 +229,14 @@ module Paperclip
|
|
|
228
229
|
end
|
|
229
230
|
end
|
|
230
231
|
|
|
232
|
+
def load_credentials_from_file(path)
|
|
233
|
+
if Gem::Version.new(Psych::VERSION) >= Gem::Version.new("3.1.0")
|
|
234
|
+
YAML::safe_load(ERB.new(File.read(path)).result, aliases: true)
|
|
235
|
+
else
|
|
236
|
+
YAML::safe_load(ERB.new(File.read(path)).result, [], [], true)
|
|
237
|
+
end
|
|
238
|
+
end
|
|
239
|
+
|
|
231
240
|
def connection
|
|
232
241
|
@connection ||= ::Fog::Storage.new(fog_credentials)
|
|
233
242
|
end
|
data/lib/paperclip/storage/s3.rb
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
module Paperclip
|
|
2
4
|
module Storage
|
|
3
5
|
# Amazon's S3 file hosting service is a scalable, easy place to store files for
|
|
@@ -125,8 +127,7 @@ module Paperclip
|
|
|
125
127
|
begin
|
|
126
128
|
require "aws-sdk-s3"
|
|
127
129
|
rescue LoadError => e
|
|
128
|
-
e.message
|
|
129
|
-
raise e
|
|
130
|
+
raise("#{e.message} (You may need to install the aws-sdk-s3 gem)")
|
|
130
131
|
end
|
|
131
132
|
|
|
132
133
|
base.instance_eval do
|
|
@@ -280,6 +281,16 @@ module Paperclip
|
|
|
280
281
|
s3_bucket.object style_name_as_path(style_name)
|
|
281
282
|
end
|
|
282
283
|
|
|
284
|
+
def s3_transfer_manager
|
|
285
|
+
@s3_transfer_manager ||= begin
|
|
286
|
+
if ::Aws::S3.const_defined?(:TransferManager, false)
|
|
287
|
+
::Aws::S3::TransferManager.new(client: s3_interface.client)
|
|
288
|
+
else
|
|
289
|
+
nil
|
|
290
|
+
end
|
|
291
|
+
end
|
|
292
|
+
end
|
|
293
|
+
|
|
283
294
|
def use_accelerate_endpoint?
|
|
284
295
|
!!@use_accelerate_endpoint
|
|
285
296
|
end
|
|
@@ -386,7 +397,12 @@ module Paperclip
|
|
|
386
397
|
write_options[:metadata] = @s3_metadata unless @s3_metadata.empty?
|
|
387
398
|
write_options.merge!(@s3_headers)
|
|
388
399
|
|
|
389
|
-
|
|
400
|
+
if s3_transfer_manager
|
|
401
|
+
destination = style_name_as_path(style)
|
|
402
|
+
s3_transfer_manager.upload_file(file.path, **write_options, bucket: bucket_name, key: destination)
|
|
403
|
+
else
|
|
404
|
+
s3_object(style).upload_file(file.path, write_options)
|
|
405
|
+
end
|
|
390
406
|
rescue ::Aws::S3::Errors::NoSuchBucket
|
|
391
407
|
create_bucket
|
|
392
408
|
retry
|
|
@@ -422,7 +438,13 @@ module Paperclip
|
|
|
422
438
|
|
|
423
439
|
def copy_to_local_file(style, local_dest_path)
|
|
424
440
|
log("copying #{path(style)} to local file #{local_dest_path}")
|
|
425
|
-
|
|
441
|
+
|
|
442
|
+
if s3_transfer_manager
|
|
443
|
+
source = style_name_as_path(style)
|
|
444
|
+
s3_transfer_manager.download_file(local_dest_path, bucket: bucket_name, key: source)
|
|
445
|
+
else
|
|
446
|
+
s3_object(style).download_file(local_dest_path)
|
|
447
|
+
end
|
|
426
448
|
rescue Aws::Errors::ServiceError => e
|
|
427
449
|
warn("#{e} - cannot copy #{path(style)} to local file #{local_dest_path}")
|
|
428
450
|
false
|
|
@@ -433,7 +455,7 @@ module Paperclip
|
|
|
433
455
|
def find_credentials(creds)
|
|
434
456
|
case creds
|
|
435
457
|
when File
|
|
436
|
-
|
|
458
|
+
load_credentials_from_file(creds.path)
|
|
437
459
|
when String, Pathname
|
|
438
460
|
load_credentials_from_file(creds)
|
|
439
461
|
when Hash
|
data/lib/paperclip/storage.rb
CHANGED
data/lib/paperclip/style.rb
CHANGED
data/lib/paperclip/tempfile.rb
CHANGED
data/lib/paperclip/thumbnail.rb
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
module Paperclip
|
|
2
4
|
# Handles thumbnailing images that are uploaded.
|
|
3
5
|
class Thumbnail < Processor
|
|
@@ -31,8 +33,8 @@ module Paperclip
|
|
|
31
33
|
|
|
32
34
|
geometry = options[:geometry].to_s
|
|
33
35
|
@crop = geometry[-1, 1] == "#"
|
|
34
|
-
@target_geometry = options.fetch(:string_geometry_parser,
|
|
35
|
-
@current_geometry = options.fetch(:file_geometry_parser,
|
|
36
|
+
@target_geometry = options.fetch(:string_geometry_parser, Commands::ImageMagick::GeometryParser).parse(geometry)
|
|
37
|
+
@current_geometry = options.fetch(:file_geometry_parser, Commands::ImageMagick::GeometryParser).from_file(@file)
|
|
36
38
|
@source_file_options = options[:source_file_options]
|
|
37
39
|
@convert_options = options[:convert_options]
|
|
38
40
|
@whiny = options.fetch(:whiny, true)
|
|
@@ -84,10 +86,8 @@ module Paperclip
|
|
|
84
86
|
rescue Terrapin::ExitStatusError => e
|
|
85
87
|
if @whiny
|
|
86
88
|
message = "There was an error processing the thumbnail for #{@basename}:\n" + e.message
|
|
87
|
-
raise Paperclip::Error
|
|
89
|
+
raise Paperclip::Error.new(message)
|
|
88
90
|
end
|
|
89
|
-
rescue Terrapin::CommandNotFoundError => e
|
|
90
|
-
raise Paperclip::Errors::CommandNotFoundError.new("Could not run the `convert` command. Please install ImageMagick.")
|
|
91
91
|
end
|
|
92
92
|
|
|
93
93
|
dst
|
|
@@ -119,13 +119,12 @@ module Paperclip
|
|
|
119
119
|
# Return true if ImageMagick's +identify+ returns an animated format
|
|
120
120
|
def identified_as_animated?
|
|
121
121
|
if @identified_as_animated.nil?
|
|
122
|
-
|
|
122
|
+
output = identify("-format %m :file", file: "#{@file.path}[0]").to_s.downcase.strip
|
|
123
|
+
@identified_as_animated = ANIMATED_FORMATS.include?(output)
|
|
123
124
|
end
|
|
124
125
|
@identified_as_animated
|
|
125
|
-
rescue Terrapin::ExitStatusError
|
|
126
|
-
raise Paperclip::Error
|
|
127
|
-
rescue Terrapin::CommandNotFoundError => e
|
|
128
|
-
raise Paperclip::Errors::CommandNotFoundError.new("Could not run the `identify` command. Please install ImageMagick.")
|
|
126
|
+
rescue Terrapin::ExitStatusError
|
|
127
|
+
raise Paperclip::Error.new("There was an error running `identify` for #{@basename}") if @whiny
|
|
129
128
|
end
|
|
130
129
|
end
|
|
131
130
|
end
|
data/lib/paperclip/validators.rb
CHANGED
data/lib/paperclip/version.rb
CHANGED
data/lib/paperclip.rb
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
# Paperclip allows file attachments that are stored in the filesystem. All graphical
|
|
2
4
|
# transformations are done using the Graphics/ImageMagick command line utilities and
|
|
3
5
|
# are stored in Tempfiles until the record is saved. Paperclip does not require a
|
|
@@ -29,8 +31,13 @@ require "erb"
|
|
|
29
31
|
require "digest"
|
|
30
32
|
require "tempfile"
|
|
31
33
|
require "paperclip/version"
|
|
32
|
-
require "paperclip/
|
|
33
|
-
require "paperclip/
|
|
34
|
+
require "paperclip/commands/runner"
|
|
35
|
+
require "paperclip/commands/imagemagick"
|
|
36
|
+
require "paperclip/commands/imagemagick/version_detector"
|
|
37
|
+
require "paperclip/commands/imagemagick/geometry_parser"
|
|
38
|
+
require "paperclip/commands/unix_file"
|
|
39
|
+
require "paperclip/geometry_parser_factory" # @deprectated
|
|
40
|
+
require "paperclip/geometry_detector_factory" # @deprectated
|
|
34
41
|
require "paperclip/geometry"
|
|
35
42
|
require "paperclip/processor"
|
|
36
43
|
require "paperclip/processor_helpers"
|
|
@@ -43,7 +50,7 @@ require "paperclip/style"
|
|
|
43
50
|
require "paperclip/attachment"
|
|
44
51
|
require "paperclip/storage"
|
|
45
52
|
require "paperclip/callbacks"
|
|
46
|
-
require "paperclip/file_command_content_type_detector"
|
|
53
|
+
require "paperclip/file_command_content_type_detector" # @deprectated
|
|
47
54
|
require "paperclip/media_type_spoof_detector"
|
|
48
55
|
require "paperclip/content_type_detector"
|
|
49
56
|
require "paperclip/glue"
|
|
@@ -77,6 +84,10 @@ module Paperclip
|
|
|
77
84
|
extend Logger
|
|
78
85
|
extend ProcessorHelpers
|
|
79
86
|
|
|
87
|
+
def self.deprecator
|
|
88
|
+
@deprecator ||= ActiveSupport::Deprecation.new(nil, "Paperclip")
|
|
89
|
+
end
|
|
90
|
+
|
|
80
91
|
# Provides configurability to Paperclip. The options available are:
|
|
81
92
|
# * whiny: Will raise an error if Paperclip cannot process thumbnails of
|
|
82
93
|
# an uploaded image. Defaults to true.
|
|
@@ -89,8 +100,11 @@ module Paperclip
|
|
|
89
100
|
# image's orientation. Defaults to true.
|
|
90
101
|
def self.options
|
|
91
102
|
@options ||= {
|
|
92
|
-
command_path: nil,
|
|
103
|
+
command_path: nil, # @deprecated Will be removed in Paperclip 8.0.
|
|
104
|
+
file_command_path: nil,
|
|
105
|
+
imagemagick_path: nil,
|
|
93
106
|
content_type_mappings: {},
|
|
107
|
+
imagemagick_version: nil,
|
|
94
108
|
log: true,
|
|
95
109
|
log_command: true,
|
|
96
110
|
read_timeout: nil,
|
|
@@ -100,6 +114,13 @@ module Paperclip
|
|
|
100
114
|
is_windows: Gem.win_platform?,
|
|
101
115
|
add_validation_errors_to: :both
|
|
102
116
|
}
|
|
117
|
+
if @options[:command_path]
|
|
118
|
+
Paperclip.deprecator.warn(
|
|
119
|
+
"Paperclip.options[:command_path] will be removed in Paperclip 8.0. Please use " \
|
|
120
|
+
"Paperclip.options[:imagemagick_path] and/or Paperclip.options[:file_command_path] instead."
|
|
121
|
+
)
|
|
122
|
+
end
|
|
123
|
+
@options
|
|
103
124
|
end
|
|
104
125
|
|
|
105
126
|
def self.io_adapters=(new_registry)
|
data/lib/tasks/paperclip.rake
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
require "paperclip/attachment_registry"
|
|
2
4
|
|
|
3
5
|
module Paperclip
|
|
@@ -25,7 +27,7 @@ module Paperclip
|
|
|
25
27
|
end
|
|
26
28
|
|
|
27
29
|
def self.log_error(error)
|
|
28
|
-
|
|
30
|
+
warn error
|
|
29
31
|
end
|
|
30
32
|
end
|
|
31
33
|
end
|
|
@@ -40,18 +42,21 @@ namespace :paperclip do
|
|
|
40
42
|
klass = Paperclip::Task.obtain_class
|
|
41
43
|
names = Paperclip::Task.obtain_attachments(klass)
|
|
42
44
|
styles = (ENV["STYLES"] || ENV["styles"] || "").split(",").map(&:to_sym)
|
|
45
|
+
|
|
43
46
|
names.each do |name|
|
|
44
47
|
Paperclip.each_instance_with_attachment(klass, name) do |instance|
|
|
45
48
|
attachment = instance.send(name)
|
|
49
|
+
|
|
46
50
|
begin
|
|
47
51
|
attachment.reprocess!(*styles)
|
|
48
52
|
rescue StandardError => e
|
|
49
53
|
Paperclip::Task.log_error("exception while processing #{klass} ID #{instance.id}:")
|
|
50
|
-
Paperclip::Task.log_error("
|
|
54
|
+
Paperclip::Task.log_error(" #{e.message}\n")
|
|
51
55
|
end
|
|
52
|
-
|
|
56
|
+
|
|
57
|
+
if instance.errors.present?
|
|
53
58
|
Paperclip::Task.log_error("errors while processing #{klass} ID #{instance.id}:")
|
|
54
|
-
Paperclip::Task.log_error("
|
|
59
|
+
Paperclip::Task.log_error(" #{instance.errors.full_messages.join("\n ")}\n")
|
|
55
60
|
end
|
|
56
61
|
end
|
|
57
62
|
end
|