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.
Files changed (203) hide show
  1. checksums.yaml +4 -4
  2. data/LICENSE +1 -1
  3. data/README.md +24 -56
  4. data/lib/generators/paperclip/paperclip_generator.rb +3 -1
  5. data/lib/kt-paperclip.rb +2 -0
  6. data/lib/paperclip/attachment.rb +49 -30
  7. data/lib/paperclip/attachment_registry.rb +2 -0
  8. data/lib/paperclip/callbacks.rb +7 -4
  9. data/lib/paperclip/commands/imagemagick/geometry_parser.rb +63 -0
  10. data/lib/paperclip/commands/imagemagick/version_detector.rb +41 -0
  11. data/lib/paperclip/commands/imagemagick.rb +44 -0
  12. data/lib/paperclip/commands/runner.rb +38 -0
  13. data/lib/paperclip/commands/unix_file.rb +28 -0
  14. data/lib/paperclip/content_type_detector.rb +31 -32
  15. data/lib/paperclip/errors.rb +2 -0
  16. data/lib/paperclip/file_command_content_type_detector.rb +11 -12
  17. data/lib/paperclip/filename_cleaner.rb +2 -0
  18. data/lib/paperclip/geometry.rb +22 -7
  19. data/lib/paperclip/geometry_detector_factory.rb +11 -31
  20. data/lib/paperclip/geometry_parser_factory.rb +13 -17
  21. data/lib/paperclip/glue.rb +2 -0
  22. data/lib/paperclip/has_attached_file.rb +2 -0
  23. data/lib/paperclip/helpers.rb +5 -25
  24. data/lib/paperclip/interpolations/plural_cache.rb +2 -0
  25. data/lib/paperclip/interpolations.rb +2 -0
  26. data/lib/paperclip/io_adapters/abstract_adapter.rb +3 -1
  27. data/lib/paperclip/io_adapters/attachment_adapter.rb +11 -0
  28. data/lib/paperclip/io_adapters/data_uri_adapter.rb +2 -0
  29. data/lib/paperclip/io_adapters/empty_string_adapter.rb +2 -0
  30. data/lib/paperclip/io_adapters/file_adapter.rb +2 -0
  31. data/lib/paperclip/io_adapters/http_url_proxy_adapter.rb +2 -0
  32. data/lib/paperclip/io_adapters/identity_adapter.rb +2 -0
  33. data/lib/paperclip/io_adapters/nil_adapter.rb +2 -0
  34. data/lib/paperclip/io_adapters/registry.rb +2 -0
  35. data/lib/paperclip/io_adapters/stringio_adapter.rb +2 -0
  36. data/lib/paperclip/io_adapters/uploaded_file_adapter.rb +2 -0
  37. data/lib/paperclip/io_adapters/uri_adapter.rb +5 -13
  38. data/lib/paperclip/locales/fr.yml +18 -0
  39. data/lib/paperclip/locales/gd.yml +1 -1
  40. data/lib/paperclip/logger.rb +2 -0
  41. data/lib/paperclip/matchers/have_attached_file_matcher.rb +2 -0
  42. data/lib/paperclip/matchers/validate_attachment_content_type_matcher.rb +5 -3
  43. data/lib/paperclip/matchers/validate_attachment_presence_matcher.rb +2 -0
  44. data/lib/paperclip/matchers/validate_attachment_size_matcher.rb +2 -0
  45. data/lib/paperclip/matchers.rb +2 -0
  46. data/lib/paperclip/media_type_spoof_detector.rb +3 -10
  47. data/lib/paperclip/missing_attachment_styles.rb +2 -0
  48. data/lib/paperclip/processor.rb +6 -19
  49. data/lib/paperclip/processor_helpers.rb +2 -0
  50. data/lib/paperclip/rails_environment.rb +2 -0
  51. data/lib/paperclip/railtie.rb +2 -0
  52. data/lib/paperclip/schema.rb +6 -4
  53. data/lib/paperclip/storage/filesystem.rb +2 -0
  54. data/lib/paperclip/storage/fog.rb +13 -4
  55. data/lib/paperclip/storage/s3.rb +27 -5
  56. data/lib/paperclip/storage.rb +2 -0
  57. data/lib/paperclip/style.rb +2 -0
  58. data/lib/paperclip/tempfile.rb +2 -0
  59. data/lib/paperclip/tempfile_factory.rb +2 -0
  60. data/lib/paperclip/thumbnail.rb +9 -10
  61. data/lib/paperclip/url_generator.rb +2 -0
  62. data/lib/paperclip/validators/attachment_content_type_validator.rb +2 -0
  63. data/lib/paperclip/validators/attachment_file_name_validator.rb +2 -0
  64. data/lib/paperclip/validators/attachment_file_type_ignorance_validator.rb +2 -0
  65. data/lib/paperclip/validators/attachment_presence_validator.rb +2 -0
  66. data/lib/paperclip/validators/attachment_size_validator.rb +2 -0
  67. data/lib/paperclip/validators/media_type_spoof_detection_validator.rb +2 -0
  68. data/lib/paperclip/validators.rb +2 -0
  69. data/lib/paperclip/version.rb +3 -1
  70. data/lib/paperclip.rb +25 -4
  71. data/lib/tasks/paperclip.rake +9 -4
  72. data/shoulda_macros/paperclip.rb +2 -0
  73. metadata +19 -538
  74. data/.codeclimate.yml +0 -17
  75. data/.github/FUNDING.yml +0 -3
  76. data/.github/ISSUE_TEMPLATE/bug_report.md +0 -38
  77. data/.github/ISSUE_TEMPLATE/custom.md +0 -10
  78. data/.github/ISSUE_TEMPLATE/feature_request.md +0 -20
  79. data/.gitignore +0 -19
  80. data/.hound.yml +0 -3
  81. data/.rubocop.yml +0 -1061
  82. data/.travis.yml +0 -45
  83. data/Appraisals +0 -30
  84. data/CONTRIBUTING.md +0 -85
  85. data/Gemfile +0 -19
  86. data/NEWS +0 -554
  87. data/RELEASING.md +0 -17
  88. data/Rakefile +0 -52
  89. data/UPGRADING +0 -17
  90. data/features/basic_integration.feature +0 -85
  91. data/features/migration.feature +0 -29
  92. data/features/rake_tasks.feature +0 -62
  93. data/features/step_definitions/attachment_steps.rb +0 -120
  94. data/features/step_definitions/html_steps.rb +0 -15
  95. data/features/step_definitions/rails_steps.rb +0 -257
  96. data/features/step_definitions/s3_steps.rb +0 -14
  97. data/features/step_definitions/web_steps.rb +0 -106
  98. data/features/support/env.rb +0 -12
  99. data/features/support/fakeweb.rb +0 -11
  100. data/features/support/file_helpers.rb +0 -34
  101. data/features/support/fixtures/boot_config.txt +0 -15
  102. data/features/support/fixtures/gemfile.txt +0 -5
  103. data/features/support/fixtures/preinitializer.txt +0 -20
  104. data/features/support/paths.rb +0 -28
  105. data/features/support/rails.rb +0 -39
  106. data/features/support/selectors.rb +0 -19
  107. data/gemfiles/4.2.gemfile +0 -20
  108. data/gemfiles/5.0.gemfile +0 -20
  109. data/gemfiles/5.1.gemfile +0 -20
  110. data/gemfiles/5.2.gemfile +0 -20
  111. data/gemfiles/6.0.gemfile +0 -20
  112. data/gemfiles/6.1.gemfile +0 -21
  113. data/gemfiles/7.0.gemfile +0 -21
  114. data/paperclip.gemspec +0 -50
  115. data/spec/database.yml +0 -4
  116. data/spec/paperclip/attachment_definitions_spec.rb +0 -13
  117. data/spec/paperclip/attachment_processing_spec.rb +0 -79
  118. data/spec/paperclip/attachment_registry_spec.rb +0 -158
  119. data/spec/paperclip/attachment_spec.rb +0 -1590
  120. data/spec/paperclip/content_type_detector_spec.rb +0 -54
  121. data/spec/paperclip/file_command_content_type_detector_spec.rb +0 -40
  122. data/spec/paperclip/filename_cleaner_spec.rb +0 -13
  123. data/spec/paperclip/geometry_detector_spec.rb +0 -47
  124. data/spec/paperclip/geometry_parser_spec.rb +0 -73
  125. data/spec/paperclip/geometry_spec.rb +0 -267
  126. data/spec/paperclip/glue_spec.rb +0 -63
  127. data/spec/paperclip/has_attached_file_spec.rb +0 -78
  128. data/spec/paperclip/integration_spec.rb +0 -702
  129. data/spec/paperclip/interpolations_spec.rb +0 -270
  130. data/spec/paperclip/io_adapters/abstract_adapter_spec.rb +0 -160
  131. data/spec/paperclip/io_adapters/attachment_adapter_spec.rb +0 -140
  132. data/spec/paperclip/io_adapters/data_uri_adapter_spec.rb +0 -88
  133. data/spec/paperclip/io_adapters/empty_string_adapter_spec.rb +0 -17
  134. data/spec/paperclip/io_adapters/file_adapter_spec.rb +0 -131
  135. data/spec/paperclip/io_adapters/http_url_proxy_adapter_spec.rb +0 -142
  136. data/spec/paperclip/io_adapters/identity_adapter_spec.rb +0 -8
  137. data/spec/paperclip/io_adapters/nil_adapter_spec.rb +0 -25
  138. data/spec/paperclip/io_adapters/registry_spec.rb +0 -35
  139. data/spec/paperclip/io_adapters/stringio_adapter_spec.rb +0 -64
  140. data/spec/paperclip/io_adapters/uploaded_file_adapter_spec.rb +0 -146
  141. data/spec/paperclip/io_adapters/uri_adapter_spec.rb +0 -231
  142. data/spec/paperclip/matchers/have_attached_file_matcher_spec.rb +0 -19
  143. data/spec/paperclip/matchers/validate_attachment_content_type_matcher_spec.rb +0 -108
  144. data/spec/paperclip/matchers/validate_attachment_presence_matcher_spec.rb +0 -69
  145. data/spec/paperclip/matchers/validate_attachment_size_matcher_spec.rb +0 -88
  146. data/spec/paperclip/media_type_spoof_detector_spec.rb +0 -126
  147. data/spec/paperclip/meta_class_spec.rb +0 -30
  148. data/spec/paperclip/paperclip_missing_attachment_styles_spec.rb +0 -88
  149. data/spec/paperclip/paperclip_spec.rb +0 -196
  150. data/spec/paperclip/plural_cache_spec.rb +0 -37
  151. data/spec/paperclip/processor_helpers_spec.rb +0 -57
  152. data/spec/paperclip/processor_spec.rb +0 -26
  153. data/spec/paperclip/rails_environment_spec.rb +0 -30
  154. data/spec/paperclip/rake_spec.rb +0 -103
  155. data/spec/paperclip/schema_spec.rb +0 -252
  156. data/spec/paperclip/storage/filesystem_spec.rb +0 -102
  157. data/spec/paperclip/storage/fog_spec.rb +0 -606
  158. data/spec/paperclip/storage/s3_live_spec.rb +0 -188
  159. data/spec/paperclip/storage/s3_spec.rb +0 -1878
  160. data/spec/paperclip/style_spec.rb +0 -251
  161. data/spec/paperclip/tempfile_factory_spec.rb +0 -33
  162. data/spec/paperclip/tempfile_spec.rb +0 -35
  163. data/spec/paperclip/thumbnail_spec.rb +0 -504
  164. data/spec/paperclip/url_generator_spec.rb +0 -231
  165. data/spec/paperclip/validators/attachment_content_type_validator_spec.rb +0 -410
  166. data/spec/paperclip/validators/attachment_file_name_validator_spec.rb +0 -249
  167. data/spec/paperclip/validators/attachment_presence_validator_spec.rb +0 -85
  168. data/spec/paperclip/validators/attachment_size_validator_spec.rb +0 -325
  169. data/spec/paperclip/validators/media_type_spoof_detection_validator_spec.rb +0 -48
  170. data/spec/paperclip/validators_spec.rb +0 -179
  171. data/spec/spec_helper.rb +0 -46
  172. data/spec/support/assertions.rb +0 -84
  173. data/spec/support/fake_model.rb +0 -24
  174. data/spec/support/fake_rails.rb +0 -12
  175. data/spec/support/fixtures/12k.png +0 -0
  176. data/spec/support/fixtures/50x50.png +0 -0
  177. data/spec/support/fixtures/5k.png +0 -0
  178. data/spec/support/fixtures/animated +0 -0
  179. data/spec/support/fixtures/animated.gif +0 -0
  180. data/spec/support/fixtures/animated.unknown +0 -0
  181. data/spec/support/fixtures/aws_s3.yml +0 -13
  182. data/spec/support/fixtures/bad.png +0 -1
  183. data/spec/support/fixtures/empty.html +0 -1
  184. data/spec/support/fixtures/empty.xlsx +0 -0
  185. data/spec/support/fixtures/fog.yml +0 -8
  186. data/spec/support/fixtures/rotated.jpg +0 -0
  187. data/spec/support/fixtures/s3.yml +0 -8
  188. data/spec/support/fixtures/sample.xlsm +0 -0
  189. data/spec/support/fixtures/spaced file.jpg +0 -0
  190. data/spec/support/fixtures/spaced file.png +0 -0
  191. data/spec/support/fixtures/text.txt +0 -1
  192. data/spec/support/fixtures/twopage.pdf +0 -0
  193. data/spec/support/fixtures/uppercase.PNG +0 -0
  194. data/spec/support/matchers/accept.rb +0 -5
  195. data/spec/support/matchers/exist.rb +0 -5
  196. data/spec/support/matchers/have_column.rb +0 -23
  197. data/spec/support/mock_attachment.rb +0 -24
  198. data/spec/support/mock_interpolator.rb +0 -24
  199. data/spec/support/mock_url_generator_builder.rb +0 -26
  200. data/spec/support/model_reconstruction.rb +0 -72
  201. data/spec/support/reporting.rb +0 -11
  202. data/spec/support/test_data.rb +0 -13
  203. 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 << " (You may need to install the fog gem)"
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
- YAML::safe_load(ERB.new(File.read(creds.path)).result)
218
+ load_credentials_from_file(creds.path)
218
219
  when String, Pathname
219
- YAML::safe_load(ERB.new(File.read(creds)).result)
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
@@ -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 << " (You may need to install the aws-sdk-s3 gem)"
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
- s3_object(style).upload_file(file.path, write_options)
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
- s3_object(style).download_file(local_dest_path)
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
- load_credentials_from_file(creds.path)
458
+ load_credentials_from_file(creds.path)
437
459
  when String, Pathname
438
460
  load_credentials_from_file(creds)
439
461
  when Hash
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require "paperclip/storage/filesystem"
2
4
  require "paperclip/storage/fog"
3
5
  require "paperclip/storage/s3"
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Paperclip
2
4
  # The Style class holds the definition of a thumbnail style, applying
3
5
  # whatever processing is required to normalize the definition and delaying
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Paperclip
2
4
  # Overriding some implementation of Tempfile
3
5
  class Tempfile < ::Tempfile
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Paperclip
2
4
  class TempfileFactory
3
5
  def generate(name = random_name)
@@ -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, Geometry).parse(geometry)
35
- @current_geometry = options.fetch(:file_geometry_parser, Geometry).from_file(@file)
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, message
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
- @identified_as_animated = ANIMATED_FORMATS.include? identify("-format %m :file", file: "#{@file.path}[0]").to_s.downcase.strip
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 => e
126
- raise Paperclip::Error, "There was an error running `identify` for #{@basename}" if @whiny
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
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require "uri"
2
4
  require "active_support/core_ext/module/delegation"
3
5
 
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Paperclip
2
4
  module Validators
3
5
  class AttachmentContentTypeValidator < ActiveModel::EachValidator
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Paperclip
2
4
  module Validators
3
5
  class AttachmentFileNameValidator < ActiveModel::EachValidator
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require "active_model/validations/presence"
2
4
 
3
5
  module Paperclip
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require "active_model/validations/presence"
2
4
 
3
5
  module Paperclip
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require "active_model/validations/numericality"
2
4
 
3
5
  module Paperclip
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require "active_model/validations/presence"
2
4
 
3
5
  module Paperclip
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require "active_model"
2
4
  require "active_support/concern"
3
5
  require "active_support/core_ext/array/wrap"
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Paperclip
2
- VERSION = "7.2.2" unless defined?(Paperclip::VERSION)
4
+ VERSION = "8.0.0" unless defined?(Paperclip::VERSION)
3
5
  end
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/geometry_parser_factory"
33
- require "paperclip/geometry_detector_factory"
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)
@@ -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
- $stderr.puts error
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(" " + e.message + "\n")
54
+ Paperclip::Task.log_error(" #{e.message}\n")
51
55
  end
52
- unless instance.errors.blank?
56
+
57
+ if instance.errors.present?
53
58
  Paperclip::Task.log_error("errors while processing #{klass} ID #{instance.id}:")
54
- Paperclip::Task.log_error(" " + instance.errors.full_messages.join("\n ") + "\n")
59
+ Paperclip::Task.log_error(" #{instance.errors.full_messages.join("\n ")}\n")
55
60
  end
56
61
  end
57
62
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require "paperclip/matchers"
2
4
 
3
5
  module Paperclip