kt-paperclip 5.4.0 → 7.1.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (159) hide show
  1. checksums.yaml +4 -4
  2. data/.github/FUNDING.yml +3 -0
  3. data/.github/ISSUE_TEMPLATE/bug_report.md +38 -0
  4. data/.github/ISSUE_TEMPLATE/custom.md +10 -0
  5. data/.github/ISSUE_TEMPLATE/feature_request.md +20 -0
  6. data/.hound.yml +3 -1055
  7. data/.rubocop.yml +1061 -1
  8. data/.travis.yml +23 -4
  9. data/Appraisals +23 -0
  10. data/CONTRIBUTING.md +4 -5
  11. data/Gemfile +10 -7
  12. data/NEWS +52 -0
  13. data/README.md +58 -46
  14. data/Rakefile +29 -21
  15. data/UPGRADING +3 -3
  16. data/features/basic_integration.feature +4 -0
  17. data/features/migration.feature +10 -51
  18. data/features/step_definitions/attachment_steps.rb +23 -13
  19. data/features/step_definitions/html_steps.rb +5 -5
  20. data/features/step_definitions/rails_steps.rb +29 -9
  21. data/features/step_definitions/s3_steps.rb +3 -3
  22. data/features/step_definitions/web_steps.rb +5 -6
  23. data/features/support/env.rb +4 -4
  24. data/features/support/fakeweb.rb +3 -5
  25. data/features/support/file_helpers.rb +2 -2
  26. data/features/support/paths.rb +4 -4
  27. data/features/support/rails.rb +7 -7
  28. data/features/support/selectors.rb +1 -1
  29. data/gemfiles/4.2.gemfile +7 -4
  30. data/gemfiles/5.0.gemfile +7 -4
  31. data/gemfiles/5.1.gemfile +20 -0
  32. data/gemfiles/5.2.gemfile +20 -0
  33. data/gemfiles/6.0.gemfile +20 -0
  34. data/gemfiles/6.1.gemfile +21 -0
  35. data/gemfiles/7.0.gemfile +21 -0
  36. data/lib/generators/paperclip/paperclip_generator.rb +6 -8
  37. data/lib/paperclip/attachment.rb +103 -105
  38. data/lib/paperclip/attachment_registry.rb +2 -2
  39. data/lib/paperclip/content_type_detector.rb +10 -5
  40. data/lib/paperclip/file_command_content_type_detector.rb +1 -3
  41. data/lib/paperclip/filename_cleaner.rb +0 -1
  42. data/lib/paperclip/geometry.rb +18 -19
  43. data/lib/paperclip/geometry_detector_factory.rb +13 -16
  44. data/lib/paperclip/geometry_parser_factory.rb +5 -5
  45. data/lib/paperclip/glue.rb +3 -3
  46. data/lib/paperclip/has_attached_file.rb +5 -4
  47. data/lib/paperclip/helpers.rb +3 -3
  48. data/lib/paperclip/interpolations.rb +42 -38
  49. data/lib/paperclip/io_adapters/abstract_adapter.rb +16 -14
  50. data/lib/paperclip/io_adapters/attachment_adapter.rb +12 -6
  51. data/lib/paperclip/io_adapters/data_uri_adapter.rb +1 -1
  52. data/lib/paperclip/io_adapters/file_adapter.rb +1 -3
  53. data/lib/paperclip/io_adapters/http_url_proxy_adapter.rb +1 -1
  54. data/lib/paperclip/io_adapters/identity_adapter.rb +1 -2
  55. data/lib/paperclip/io_adapters/registry.rb +1 -1
  56. data/lib/paperclip/io_adapters/stringio_adapter.rb +1 -1
  57. data/lib/paperclip/io_adapters/uploaded_file_adapter.rb +6 -8
  58. data/lib/paperclip/io_adapters/uri_adapter.rb +21 -9
  59. data/lib/paperclip/logger.rb +1 -1
  60. data/lib/paperclip/matchers/have_attached_file_matcher.rb +4 -4
  61. data/lib/paperclip/matchers/validate_attachment_content_type_matcher.rb +19 -18
  62. data/lib/paperclip/matchers/validate_attachment_presence_matcher.rb +4 -4
  63. data/lib/paperclip/matchers/validate_attachment_size_matcher.rb +11 -10
  64. data/lib/paperclip/matchers.rb +4 -4
  65. data/lib/paperclip/media_type_spoof_detector.rb +13 -13
  66. data/lib/paperclip/missing_attachment_styles.rb +11 -6
  67. data/lib/paperclip/processor.rb +13 -6
  68. data/lib/paperclip/processor_helpers.rb +3 -1
  69. data/lib/paperclip/rails_environment.rb +1 -5
  70. data/lib/paperclip/railtie.rb +5 -5
  71. data/lib/paperclip/schema.rb +16 -12
  72. data/lib/paperclip/storage/filesystem.rb +6 -8
  73. data/lib/paperclip/storage/fog.rb +36 -32
  74. data/lib/paperclip/storage/s3.rb +68 -76
  75. data/lib/paperclip/style.rb +3 -6
  76. data/lib/paperclip/tempfile.rb +4 -5
  77. data/lib/paperclip/tempfile_factory.rb +0 -1
  78. data/lib/paperclip/thumbnail.rb +11 -11
  79. data/lib/paperclip/url_generator.rb +5 -5
  80. data/lib/paperclip/validators/attachment_content_type_validator.rb +11 -4
  81. data/lib/paperclip/validators/attachment_file_name_validator.rb +14 -12
  82. data/lib/paperclip/validators/attachment_file_type_ignorance_validator.rb +1 -2
  83. data/lib/paperclip/validators/attachment_presence_validator.rb +3 -5
  84. data/lib/paperclip/validators/attachment_size_validator.rb +28 -11
  85. data/lib/paperclip/validators/media_type_spoof_detection_validator.rb +3 -1
  86. data/lib/paperclip/validators.rb +16 -17
  87. data/lib/paperclip/version.rb +1 -3
  88. data/lib/paperclip.rb +49 -48
  89. data/lib/tasks/paperclip.rake +23 -24
  90. data/paperclip.gemspec +29 -33
  91. data/shoulda_macros/paperclip.rb +16 -16
  92. data/spec/paperclip/attachment_definitions_spec.rb +5 -5
  93. data/spec/paperclip/attachment_processing_spec.rb +22 -23
  94. data/spec/paperclip/attachment_registry_spec.rb +15 -15
  95. data/spec/paperclip/attachment_spec.rb +238 -196
  96. data/spec/paperclip/content_type_detector_spec.rb +18 -12
  97. data/spec/paperclip/file_command_content_type_detector_spec.rb +10 -10
  98. data/spec/paperclip/filename_cleaner_spec.rb +3 -4
  99. data/spec/paperclip/geometry_detector_spec.rb +7 -8
  100. data/spec/paperclip/geometry_parser_spec.rb +31 -31
  101. data/spec/paperclip/geometry_spec.rb +24 -24
  102. data/spec/paperclip/glue_spec.rb +3 -5
  103. data/spec/paperclip/has_attached_file_spec.rb +46 -126
  104. data/spec/paperclip/integration_spec.rb +111 -77
  105. data/spec/paperclip/interpolations_spec.rb +101 -93
  106. data/spec/paperclip/io_adapters/abstract_adapter_spec.rb +41 -13
  107. data/spec/paperclip/io_adapters/attachment_adapter_spec.rb +8 -10
  108. data/spec/paperclip/io_adapters/data_uri_adapter_spec.rb +13 -14
  109. data/spec/paperclip/io_adapters/empty_string_adapter_spec.rb +4 -4
  110. data/spec/paperclip/io_adapters/file_adapter_spec.rb +12 -12
  111. data/spec/paperclip/io_adapters/http_url_proxy_adapter_spec.rb +58 -37
  112. data/spec/paperclip/io_adapters/identity_adapter_spec.rb +1 -1
  113. data/spec/paperclip/io_adapters/nil_adapter_spec.rb +2 -2
  114. data/spec/paperclip/io_adapters/registry_spec.rb +4 -4
  115. data/spec/paperclip/io_adapters/stringio_adapter_spec.rb +10 -10
  116. data/spec/paperclip/io_adapters/uploaded_file_adapter_spec.rb +6 -6
  117. data/spec/paperclip/io_adapters/uri_adapter_spec.rb +90 -31
  118. data/spec/paperclip/matchers/have_attached_file_matcher_spec.rb +3 -3
  119. data/spec/paperclip/matchers/validate_attachment_content_type_matcher_spec.rb +4 -5
  120. data/spec/paperclip/matchers/validate_attachment_presence_matcher_spec.rb +4 -4
  121. data/spec/paperclip/matchers/validate_attachment_size_matcher_spec.rb +4 -4
  122. data/spec/paperclip/media_type_spoof_detector_spec.rb +50 -24
  123. data/spec/paperclip/meta_class_spec.rb +3 -3
  124. data/spec/paperclip/paperclip_missing_attachment_styles_spec.rb +28 -24
  125. data/spec/paperclip/paperclip_spec.rb +15 -11
  126. data/spec/paperclip/plural_cache_spec.rb +8 -8
  127. data/spec/paperclip/processor_helpers_spec.rb +35 -35
  128. data/spec/paperclip/processor_spec.rb +8 -8
  129. data/spec/paperclip/rails_environment_spec.rb +7 -10
  130. data/spec/paperclip/rake_spec.rb +39 -39
  131. data/spec/paperclip/schema_spec.rb +57 -53
  132. data/spec/paperclip/storage/filesystem_spec.rb +29 -6
  133. data/spec/paperclip/storage/fog_spec.rb +122 -82
  134. data/spec/paperclip/storage/s3_live_spec.rb +22 -22
  135. data/spec/paperclip/storage/s3_spec.rb +649 -583
  136. data/spec/paperclip/style_spec.rb +67 -71
  137. data/spec/paperclip/tempfile_factory_spec.rb +5 -5
  138. data/spec/paperclip/thumbnail_spec.rb +68 -67
  139. data/spec/paperclip/url_generator_spec.rb +18 -19
  140. data/spec/paperclip/validators/attachment_content_type_validator_spec.rb +115 -27
  141. data/spec/paperclip/validators/attachment_file_name_validator_spec.rb +105 -16
  142. data/spec/paperclip/validators/attachment_presence_validator_spec.rb +5 -5
  143. data/spec/paperclip/validators/attachment_size_validator_spec.rb +111 -21
  144. data/spec/paperclip/validators/media_type_spoof_detection_validator_spec.rb +9 -13
  145. data/spec/paperclip/validators_spec.rb +61 -46
  146. data/spec/spec_helper.rb +21 -23
  147. data/spec/support/assertions.rb +8 -6
  148. data/spec/support/fake_model.rb +1 -2
  149. data/spec/support/fake_rails.rb +1 -1
  150. data/spec/support/fixtures/aws_s3.yml +13 -0
  151. data/spec/support/fixtures/sample.xlsm +0 -0
  152. data/spec/support/matchers/exist.rb +1 -1
  153. data/spec/support/matchers/have_column.rb +1 -1
  154. data/spec/support/mock_url_generator_builder.rb +2 -3
  155. data/spec/support/model_reconstruction.rb +16 -12
  156. data/spec/support/reporting.rb +1 -1
  157. data/spec/support/test_data.rb +2 -2
  158. metadata +58 -106
  159. data/spec/support/conditional_filter_helper.rb +0 -5
data/.travis.yml CHANGED
@@ -1,26 +1,45 @@
1
1
  language: ruby
2
- sudo: false
3
2
 
4
3
  rvm:
5
- - 2.1
6
- - 2.2
7
4
  - 2.3
8
5
  - 2.4
6
+ - 2.5
7
+ - 2.6
9
8
  - 2.7
10
9
 
11
10
  script: "bundle exec rake clean spec cucumber"
12
11
 
13
12
  addons:
14
13
  apt:
14
+ update: true
15
15
  packages:
16
16
  - ghostscript
17
17
 
18
+ before_install:
19
+ - sudo rm /etc/ImageMagick-6/policy.xml
20
+
18
21
  gemfile:
19
22
  - gemfiles/4.2.gemfile
20
23
  - gemfiles/5.0.gemfile
24
+ - gemfiles/5.1.gemfile
25
+ - gemfiles/5.2.gemfile
26
+ - gemfiles/6.0.gemfile
27
+ - gemfiles/6.1.gemfile
21
28
 
22
29
  matrix:
23
30
  fast_finish: true
24
31
  exclude:
32
+ - gemfile: gemfiles/6.0.gemfile
33
+ rvm: 2.3
34
+ - gemfile: gemfiles/6.0.gemfile
35
+ rvm: 2.4
36
+ - gemfile: gemfiles/6.1.gemfile
37
+ rvm: 2.3
38
+ - gemfile: gemfiles/6.1.gemfile
39
+ rvm: 2.4
40
+ - gemfile: gemfiles/4.2.gemfile
41
+ rvm: 2.7
25
42
  - gemfile: gemfiles/5.0.gemfile
26
- rvm: 2.1
43
+ rvm: 2.7
44
+ - gemfile: gemfiles/5.1.gemfile
45
+ rvm: 2.7
data/Appraisals CHANGED
@@ -1,7 +1,30 @@
1
1
  appraise "4.2" do
2
+ gem "sqlite3", "~> 1.3.8", platforms: :ruby
2
3
  gem "rails", "~> 4.2.0"
3
4
  end
4
5
 
5
6
  appraise "5.0" do
7
+ gem "sqlite3", "~> 1.3.8", platforms: :ruby
6
8
  gem "rails", "~> 5.0.0"
7
9
  end
10
+
11
+ appraise "5.1" do
12
+ gem "sqlite3", "~> 1.3.8", platforms: :ruby
13
+ gem "rails", "~> 5.1.0"
14
+ end
15
+
16
+ appraise "5.2" do
17
+ gem "sqlite3", "~> 1.3.8", platforms: :ruby
18
+ gem "rails", "~> 5.2.0"
19
+ end
20
+
21
+ appraise "6.0" do
22
+ gem "sqlite3", "~> 1.4", platforms: :ruby
23
+ gem "rails", "~> 6.0.0"
24
+ end
25
+
26
+ appraise "6.1" do
27
+ gem "sqlite3", "~> 1.4", platforms: :ruby
28
+ gem "aruba", "~> 1.0", ">= 1.0.4"
29
+ gem "rails", "~> 6.1", ">= 6.1.1"
30
+ end
data/CONTRIBUTING.md CHANGED
@@ -10,8 +10,7 @@ Here's a quick guide for contributing:
10
10
 
11
11
  1. Fork the repo.
12
12
 
13
- 1. Make sure you have ImageMagick and Ghostscript installed. See [this section]
14
- (./README.md#image-processor) of the README.
13
+ 1. Make sure you have ImageMagick and Ghostscript installed. See [this section](./README.md#image-processor) of the README.
15
14
 
16
15
  1. Run the tests. We only take pull requests with passing tests, and it's great
17
16
  to know that you have a clean slate: `bundle && bundle exec rake`
@@ -78,9 +77,9 @@ Syntax
78
77
 
79
78
  * Two spaces, no tabs.
80
79
  * No trailing whitespace. Blank lines should not have any space.
81
- * Prefer &&/|| over and/or.
82
- * MyClass.my_method(my_arg) not my_method( my_arg ) or my_method my_arg.
83
- * a = b and not a=b.
80
+ * Prefer `&&` instead of `and` ; prefer `||` instead of `or`.
81
+ * Use `MyClass.my_method(my_arg)` instead of `MyClass.my_method( my_arg )` or `MyClass.my_method my_arg`.
82
+ * `a = b` rather than `a=b` .
84
83
  * Follow the conventions you see used in the source already.
85
84
 
86
85
  And in case we didn't emphasize it enough: we love tests!
data/Gemfile CHANGED
@@ -2,15 +2,18 @@ source "https://rubygems.org"
2
2
 
3
3
  gemspec
4
4
 
5
- gem 'sqlite3', '~> 1.3.8', :platforms => :ruby
6
- gem 'pry'
5
+ gem "pry"
7
6
 
8
7
  # Hinting at development dependencies
9
8
  # Prevents bundler from taking a long-time to resolve
10
9
  group :development, :test do
11
- gem 'activerecord-import'
12
- gem 'mime-types'
13
- gem 'builder'
14
- gem 'rubocop', require: false
15
- gem 'rspec'
10
+ gem "activerecord-import"
11
+ gem "bootsnap", require: false
12
+ gem "builder"
13
+ gem "listen", "~> 3.0.8"
14
+ gem "rspec"
15
+ # Hound only supports certain versions of Rubocop -- 1.22.1 is currently the most recent one supported.
16
+ gem "rubocop", "1.22.1", require: false
17
+ gem "rubocop-rails"
18
+ gem "sprockets", "3.7.2"
16
19
  end
data/NEWS CHANGED
@@ -1,3 +1,55 @@
1
+ [UNRELEASED]
2
+ Issue file delete only once per unique style when nullifying attachment or destroying an object. Avoids triggering a rate limit error on Google Cloud Storage.
3
+
4
+ 7.0.0 (2021-05-28)
5
+ * Replace `mimemagic` gem with `marcel` due to licensing issues. See https://github.com/kreeti/kt-paperclip/pull/54 for details and limitations
6
+
7
+ 6.4.1 (2021-01-30)
8
+ * Improvement: Use URI.open in ruby > 2.5 (PR #45)
9
+
10
+ 6.4.0 (2020-12-14)
11
+ * Improvement: Fix Ruby 2.7 method & syntax deprecation warnings (#38)
12
+
13
+ 6.3.0 (2020-08-10)
14
+ * Feature: Add validation_errors_to option - customize copying of errors (#26)
15
+ * Stability: Dropped support for ruby 2.1
16
+
17
+ 6.2.2 (2020-02-18)
18
+ * Bugfix: Add support for Aliases in S3 credentials YAML (accidentally removed during 6.2.0 upgrade).
19
+
20
+ 6.2.1 (2020-01-30)
21
+
22
+ * Bugfix: Auto-loading of the gem code (necessitated due to change in gem name).
23
+
24
+ 6.2.0 (2020-01-23):
25
+
26
+ * Bugfix: Don't do post-processing on invalid attachments (#16).
27
+ * Improvement: Use AWS::S3 built in download_file method (#9).
28
+ * Stability: Rubocop recommended syntax updates (#10, #11, #13, #14).
29
+ * Stability: Testing - replace mocha and bourne with rspec mocks (#6).
30
+ * Stability: Fix test suite to run with Rails 5 and Rails 6 (#19, #20, #7).
31
+
32
+ 6.1.0 (2018-07-27):
33
+
34
+ * BUGFIX: Don't double-encode URLs (Roderick Monje).
35
+ * BUGFIX: Only use the content_type when it exists (Jean-Philippe Doyle).
36
+ * STABILITY: Better handling of the content-disposition header. Now supports
37
+ file name that is either enclosed or not in double quotes and is case
38
+ insensitive as per RC6266 grammar (Hasan Kumar, Yves Riel).
39
+ * STABILITY: Change database column type of attachment file size from unsigned 4-byte
40
+ `integer` to unsigned 8-byte `bigint`. The former type limits attachment size
41
+ to just over 2GB, which can easily be exceeded by a large video file (Laurent
42
+ Arnoud, Alen Zamanyan).
43
+ * STABILITY: Better error message when thumbnail processing errors (Hayden Ball).
44
+ * STABILITY: Fix file linking issues around Windows (Akihiko Odaki).
45
+ * STABILITY: Files without an extension will now be checked for spoofing attempts
46
+ (George Walters II).
47
+ * STABILITY: Manually close Tempfiles when we are done with them (Erkki Eilonen).
48
+
49
+ 6.0.0 (2018-03-09):
50
+
51
+ * Improvement: Depend only on `aws-sdk-s3` instead of `aws-sdk` (https://github.com/thoughtbot/paperclip/pull/2481)
52
+
1
53
  5.3.0 (2018-03-09):
2
54
 
3
55
  * Improvement: Use `FactoryBot` instead of `FactoryGirl` (https://github.com/thoughtbot/paperclip/pull/2501)
data/README.md CHANGED
@@ -1,18 +1,23 @@
1
1
  Paperclip
2
2
  =========
3
3
 
4
+ We plan to support and maintain paperclip, as well as clean it up.
5
+
6
+ Please feel free to contribute Issues and pull requests.
7
+
8
+ # Existing documentation
9
+
4
10
  ## Documentation valid for `master` branch
5
11
 
6
12
  Please check the documentation for the paperclip version you are using:
7
- https://github.com/thoughtbot/paperclip/releases
13
+ https://github.com/kreeti/kt-paperclip/releases
8
14
 
9
15
  ---
10
16
 
11
- [![Build Status](https://secure.travis-ci.org/thoughtbot/paperclip.svg?branch=master)](http://travis-ci.org/thoughtbot/paperclip)
12
- [![Dependency Status](https://gemnasium.com/thoughtbot/paperclip.svg?travis)](https://gemnasium.com/thoughtbot/paperclip)
13
- [![Code Climate](https://codeclimate.com/github/thoughtbot/paperclip.svg)](https://codeclimate.com/github/thoughtbot/paperclip)
14
- [![Inline docs](http://inch-ci.org/github/thoughtbot/paperclip.svg)](http://inch-ci.org/github/thoughtbot/paperclip)
15
- [![Security](https://hakiri.io/github/thoughtbot/paperclip/master.svg)](https://hakiri.io/github/thoughtbot/paperclip/master)
17
+ [![Build Status](https://travis-ci.com/kreeti/kt-paperclip.svg?branch=master)](https://travis-ci.com/kreeti/kt-paperclip)
18
+ [![Code Climate](https://codeclimate.com/github/kreeti/paperclip.svg)](https://codeclimate.com/github/kreeti/paperclip)
19
+ [![Inline docs](http://inch-ci.org/github/kreeti/paperclip.svg)](http://inch-ci.org/github/kreeti/paperclip)
20
+ [![Security](https://hakiri.io/github/kreeti/paperclip/master.svg)](https://hakiri.io/github/kreeti/paperclip/master)
16
21
 
17
22
  <!-- START doctoc generated TOC please keep comment here to allow auto update -->
18
23
  <!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
@@ -58,7 +63,6 @@ https://github.com/thoughtbot/paperclip/releases
58
63
  - [Testing](#testing)
59
64
  - [Contributing](#contributing)
60
65
  - [License](#license)
61
- - [About thoughtbot](#about-thoughtbot)
62
66
 
63
67
  <!-- END doctoc generated TOC please keep comment here to allow auto update -->
64
68
 
@@ -74,10 +78,10 @@ packages). Attached files are saved to the filesystem and referenced in the
74
78
  browser by an easily understandable specification, which has sensible and
75
79
  useful defaults.
76
80
 
77
- See the documentation for `has_attached_file` in [`Paperclip::ClassMethods`](http://www.rubydoc.info/gems/paperclip/Paperclip/ClassMethods) for
81
+ See the documentation for `has_attached_file` in [`Paperclip::ClassMethods`](http://www.rubydoc.info/gems/kt-paperclip/Paperclip/ClassMethods) for
78
82
  more detailed options.
79
83
 
80
- The complete [RDoc](http://www.rubydoc.info/gems/paperclip) is online.
84
+ The complete [RDoc](http://www.rubydoc.info/gems/kt-paperclip) is online.
81
85
 
82
86
  ---
83
87
 
@@ -86,7 +90,7 @@ Requirements
86
90
 
87
91
  ### Ruby and Rails
88
92
 
89
- Paperclip now requires Ruby version **>= 2.1** and Rails version **>= 4.2**
93
+ Paperclip now requires Ruby version **>= 2.3** and Rails version **>= 4.2**
90
94
  (only if you're going to use Paperclip with Ruby on Rails).
91
95
 
92
96
  ### Image Processor
@@ -167,13 +171,13 @@ Paperclip is distributed as a gem, which is how it should be used in your app.
167
171
  Include the gem in your Gemfile:
168
172
 
169
173
  ```ruby
170
- gem "paperclip", "~> 5.2.1"
174
+ gem "kt-paperclip", "~> 6.4", ">= 6.4.1"
171
175
  ```
172
176
 
173
177
  Or, if you want to get the latest, you can get master from the main paperclip repository:
174
178
 
175
179
  ```ruby
176
- gem "paperclip", git: "git://github.com/thoughtbot/paperclip.git"
180
+ gem "kt-paperclip", git: "git://github.com/kreeti/kt-paperclip.git"
177
181
  ```
178
182
 
179
183
  If you're trying to use features that don't seem to be in the latest released gem, but are
@@ -305,7 +309,7 @@ You'll need to add `<attachment>_content_type` in case you want to use content t
305
309
  validation.
306
310
 
307
311
  More information about the options passed to `has_attached_file` is available in the
308
- documentation of [`Paperclip::ClassMethods`](http://www.rubydoc.info/gems/paperclip/Paperclip/ClassMethods).
312
+ documentation of [`Paperclip::ClassMethods`](http://www.rubydoc.info/gems/kt-paperclip/Paperclip/ClassMethods).
309
313
 
310
314
  Validations
311
315
  -----------
@@ -337,11 +341,11 @@ Example Usage:
337
341
  validates_attachment_presence :avatar
338
342
  ```
339
343
 
340
- Lastly, you can also define multiple validations on a single attachment using `validates_attachment`:
344
+ You can also define multiple validations on a single attachment using `validates_attachment`:
341
345
 
342
346
  ```ruby
343
347
  validates_attachment :avatar, presence: true,
344
- content_type: { content_type: "image/jpeg" },
348
+ content_type: "image/jpeg",
345
349
  size: { in: 0..10.kilobytes }
346
350
  ```
347
351
 
@@ -368,7 +372,7 @@ afterwards, then assign manually:
368
372
  ```ruby
369
373
  class Book < ActiveRecord::Base
370
374
  has_attached_file :document, styles: { thumbnail: "60x60#" }
371
- validates_attachment :document, content_type: { content_type: "application/pdf" }
375
+ validates_attachment :document, content_type: "application/pdf"
372
376
  validates_something_else # Other validations that conflict with Paperclip's
373
377
  end
374
378
 
@@ -400,19 +404,41 @@ image-y ones:
400
404
 
401
405
  ```ruby
402
406
  validates_attachment :avatar,
403
- content_type: { content_type: ["image/jpeg", "image/gif", "image/png"] }
407
+ content_type: ["image/jpeg", "image/gif", "image/png"]
404
408
  ```
405
409
 
406
410
  `Paperclip::ContentTypeDetector` will attempt to match a file's extension to an
407
411
  inferred content_type, regardless of the actual contents of the file.
408
412
 
413
+ ### Duplicate error messages
414
+
415
+ By default Paperclip will copy validation errors from the attribute to the base
416
+ of your model. Depending on how you display your validation errors, this can lead
417
+ to confusing duplicate errors (one on the attribute and another referring to the
418
+ base model).
419
+
420
+ You can override this behaviour with the `add_validation_errors_to` option. By
421
+ default this is set to `:both` but can be set to either `:attribute` or `:base`.
422
+
423
+ * `:both` creates errors on both the attribute and base model.
424
+ * `:attribute` only creates an error on the attribute of the model.
425
+ * `:base` only creates an error on the base model.
426
+
427
+ You can set this option globally:
428
+
429
+ `Paperclip.options[:add_validation_errors_to] = :attribute`
430
+
431
+ or pass it in to an individual validation declaration:
432
+
433
+ `validates_attachment :document, content_type: { content_type: "application/pdf" }, add_validation_errors_to: :attribute`
434
+
409
435
  ---
410
436
 
411
437
  Internationalization (I18n)
412
438
  ---------------------------
413
439
 
414
440
  For using or adding locale files in different languages, check the project
415
- https://github.com/thoughtbot/paperclip-i18n.
441
+ https://github.com/kreeti/paperclip-i18n.
416
442
 
417
443
  Security Validations
418
444
  ====================
@@ -567,7 +593,7 @@ Storage
567
593
  Paperclip ships with 3 storage adapters:
568
594
 
569
595
  * File Storage
570
- * S3 Storage (via `aws-sdk`)
596
+ * S3 Storage (via `aws-sdk-s3`)
571
597
  * Fog Storage
572
598
 
573
599
  If you would like to use Paperclip with another storage, you can install these
@@ -593,15 +619,15 @@ _**NOTE**: This is a change from previous versions of Paperclip, but is overall
593
619
  safer choice for the default file store._
594
620
 
595
621
  You may also choose to store your files using Amazon's S3 service. To do so, include
596
- the `aws-sdk` gem in your Gemfile:
622
+ the `aws-sdk-s3` gem in your Gemfile:
597
623
 
598
624
  ```ruby
599
- gem 'aws-sdk', '~> 2.3.0'
625
+ gem 'aws-sdk-s3'
600
626
  ```
601
627
 
602
628
  And then you can specify using S3 from `has_attached_file`.
603
629
  You can find more information about configuring and using S3 storage in
604
- [the `Paperclip::Storage::S3` documentation](http://www.rubydoc.info/gems/paperclip/Paperclip/Storage/S3).
630
+ [the `Paperclip::Storage::S3` documentation](http://www.rubydoc.info/gems/kt-paperclip/Paperclip/Storage/S3).
605
631
 
606
632
  Files on the local filesystem (and in the Rails app's public directory) will be
607
633
  available to the internet at large. If you require access control, it's
@@ -663,7 +689,7 @@ has more information on the accepted style formats.
663
689
  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
690
 
665
691
  ```ruby
666
- has_attached_file :image, styles: { regular: ['800x800>', :png]},
692
+ has_attached_file :image, styles: { regular: ['800x800>', :png]},
667
693
  source_file_options: { regular: "-density 96 -depth 8 -quality 85" },
668
694
  convert_options: { regular: "-posterize 3"}
669
695
  ```
@@ -684,7 +710,7 @@ Custom Attachment Processors
684
710
  You can write your own custom attachment processors to carry out tasks like
685
711
  adding watermarks, compressing images, or encrypting files. Custom processors
686
712
  must be defined within the `Paperclip` module, inherit from
687
- `Paperclip::Processor` (see [`lib/paperclip/processor.rb`](https://github.com/thoughtbot/paperclip/blob/master/lib/paperclip/processor.rb)),
713
+ `Paperclip::Processor` (see [`lib/paperclip/processor.rb`](https://github.com/kreeti/kt-paperclip/blob/master/lib/paperclip/processor.rb)),
688
714
  and implement a `make` method that returns a `File`. All files in your Rails
689
715
  app's `lib/paperclip` and `lib/paperclip_processors` directories will be
690
716
  automatically loaded by Paperclip. Processors are specified using the
@@ -887,7 +913,7 @@ Your::Application.configure do
887
913
  end
888
914
  ```
889
915
 
890
- More information in the [rdocs](http://www.rubydoc.info/github/thoughtbot/paperclip/Paperclip.options)
916
+ More information in the [rdocs](https://www.rubydoc.info/gems/kt-paperclip/Paperclip.options)
891
917
 
892
918
  ---
893
919
 
@@ -971,7 +997,7 @@ Testing
971
997
  -------
972
998
 
973
999
  Paperclip provides rspec-compatible matchers for testing attachments. See the
974
- documentation on [Paperclip::Shoulda::Matchers](http://www.rubydoc.info/gems/paperclip/Paperclip/Shoulda/Matchers)
1000
+ documentation on [Paperclip::Shoulda::Matchers](http://www.rubydoc.info/gems/kt-paperclip/Paperclip/Shoulda/Matchers)
975
1001
  for more information.
976
1002
 
977
1003
  **Parallel Tests**
@@ -1031,33 +1057,19 @@ If you'd like to contribute a feature or bugfix: Thanks! To make sure your
1031
1057
  fix/feature has a high chance of being included, please read the following
1032
1058
  guidelines:
1033
1059
 
1034
- 1. Post a [pull request](https://github.com/thoughtbot/paperclip/compare/).
1060
+ 1. Post a [pull request](https://github.com/kreeti/kt-paperclip/compare/).
1035
1061
  2. Make sure there are tests! We will not accept any patch that is not tested.
1036
1062
  It's a rare time when explicit tests aren't needed. If you have questions
1037
1063
  about writing tests for paperclip, please open a
1038
- [GitHub issue](https://github.com/thoughtbot/paperclip/issues/new).
1064
+ [GitHub issue](https://github.com/kreeti/kt-paperclip/issues/new).
1039
1065
 
1040
1066
  Please see [`CONTRIBUTING.md`](./CONTRIBUTING.md) for more details on contributing and running test.
1041
1067
 
1042
- Thank you to all [the contributors](https://github.com/thoughtbot/paperclip/graphs/contributors)!
1068
+ Thank you to all [the contributors](https://github.com/kreeti/kt-paperclip/graphs/contributors)!
1043
1069
 
1044
1070
  License
1045
1071
  -------
1046
1072
 
1047
- Paperclip is Copyright © 2008-2017 thoughtbot, inc. It is free software, and may be
1048
- redistributed under the terms specified in the MIT-LICENSE file.
1049
-
1050
- About thoughtbot
1051
- ----------------
1052
-
1053
- ![thoughtbot](http://presskit.thoughtbot.com/images/thoughtbot-logo-for-readmes.svg)
1054
-
1055
- Paperclip is maintained and funded by thoughtbot.
1056
- The names and logos for thoughtbot are trademarks of thoughtbot, inc.
1057
-
1058
- We love open source software!
1059
- See [our other projects][community] or
1060
- [hire us][hire] to design, develop, and grow your product.
1061
-
1062
- [community]: https://thoughtbot.com/community?utm_source=github
1063
- [hire]: https://thoughtbot.com?utm_source=github
1073
+ Copyright &copy; 2020-2021 Kreeti Technologies Pvt. Ltd.
1074
+ Copyright &copy; 2008-2017 thoughtbot, inc.
1075
+ It is free software, and may be redistributed under the terms specified in the MIT-LICENSE file.
data/Rakefile CHANGED
@@ -1,44 +1,52 @@
1
- require 'bundler/gem_tasks'
2
- require 'appraisal'
3
- require 'rspec/core/rake_task'
4
- require 'cucumber/rake/task'
1
+ require "bundler/gem_tasks"
2
+ require "appraisal"
3
+ require "rspec/core/rake_task"
4
+ require "cucumber/rake/task"
5
5
 
6
- desc 'Default: run unit tests.'
7
- task :default => [:clean, :all]
6
+ desc "Default: run unit tests."
7
+ task default: [:clean, :all]
8
8
 
9
- desc 'Test the paperclip plugin under all supported Rails versions.'
10
- task :all do |t|
11
- if ENV['BUNDLE_GEMFILE']
12
- exec('rake spec && cucumber')
9
+ desc "Test the paperclip plugin under all supported Rails versions."
10
+ task :all do |_t|
11
+ if ENV["BUNDLE_GEMFILE"]
12
+ exec("rake spec && cucumber")
13
13
  else
14
14
  exec("rm -f gemfiles/*.lock")
15
15
  Rake::Task["appraisal:gemfiles"].execute
16
16
  Rake::Task["appraisal:install"].execute
17
- exec('rake appraisal')
17
+ exec("rake appraisal")
18
18
  end
19
19
  end
20
20
 
21
- desc 'Test the paperclip plugin.'
21
+ desc "Test the paperclip plugin."
22
22
  RSpec::Core::RakeTask.new(:spec)
23
23
 
24
- desc 'Run integration test'
24
+ desc "Run integration test"
25
25
  Cucumber::Rake::Task.new do |t|
26
26
  t.cucumber_opts = %w{--format progress}
27
27
  end
28
28
 
29
- desc 'Start an IRB session with all necessary files required.'
30
- task :shell do |t|
29
+ desc "Start an IRB session with all necessary files required."
30
+ task :shell do |_t|
31
31
  chdir File.dirname(__FILE__)
32
- exec 'irb -I lib/ -I lib/paperclip -r rubygems -r active_record -r tempfile -r init'
32
+ exec "irb -I lib/ -I lib/paperclip -r rubygems -r active_record -r tempfile -r init"
33
33
  end
34
34
 
35
- desc 'Clean up files.'
36
- task :clean do |t|
35
+ desc "Clean up files."
36
+ task :clean do |_t|
37
37
  FileUtils.rm_rf "doc"
38
38
  FileUtils.rm_rf "tmp"
39
39
  FileUtils.rm_rf "pkg"
40
40
  FileUtils.rm_rf "public"
41
- FileUtils.rm "test/debug.log" rescue nil
42
- FileUtils.rm "test/paperclip.db" rescue nil
43
- Dir.glob("paperclip-*.gem").each{|f| FileUtils.rm f }
41
+ begin
42
+ FileUtils.rm "test/debug.log"
43
+ rescue StandardError
44
+ nil
45
+ end
46
+ begin
47
+ FileUtils.rm "test/paperclip.db"
48
+ rescue StandardError
49
+ nil
50
+ end
51
+ Dir.glob("paperclip-*.gem").each { |f| FileUtils.rm f }
44
52
  end
data/UPGRADING CHANGED
@@ -2,9 +2,9 @@
2
2
  # NOTE FOR UPGRADING FROM 4.3.0 OR EARLIER #
3
3
  ##################################################
4
4
 
5
- Paperclip is now compatible with aws-sdk >= 2.0.0.
5
+ Paperclip is now compatible with aws-sdk-s3.
6
6
 
7
- If you are using S3 storage, aws-sdk >= 2.0.0 requires you to make a few small
7
+ If you are using S3 storage, aws-sdk-s3 requires you to make a few small
8
8
  changes:
9
9
 
10
10
  * You must set the `s3_region`
@@ -13,5 +13,5 @@ changes:
13
13
  using a hyphen. For example, `:public_read` needs to be changed to
14
14
  `public-read`.
15
15
 
16
- For a walkthrough of upgrading from 4 to 5 and aws-sdk >= 2.0 you can watch
16
+ For a walkthrough of upgrading from 4 to *5* (not 6) and aws-sdk >= 2.0 you can watch
17
17
  http://rubythursday.com/episodes/ruby-snack-27-upgrade-paperclip-and-aws-sdk-in-prep-for-rails-5
@@ -8,6 +8,10 @@ Feature: Rails integration
8
8
  And I update my new user view to include the file upload field
9
9
  And I update my user view to include the attachment
10
10
  And I allow the attachment to be submitted
11
+ And I replace this snippet to app/views/layouts/application.html.erb:
12
+ """
13
+ <%= javascript_tag 'application', 'data-turbolinks-track': 'reload' %>
14
+ """
11
15
 
12
16
  Scenario: Configure defaults for all attachments through Railtie
13
17
  Given I add this snippet to config/application.rb:
@@ -2,69 +2,28 @@ Feature: Migration
2
2
 
3
3
  Background:
4
4
  Given I generate a new rails application
5
- And I write to "app/models/user.rb" with:
6
- """
7
- class User < ActiveRecord::Base; end
8
- """
5
+ And I generate a "User" model:
9
6
 
10
7
  Scenario: Vintage syntax
11
- When I write to "db/migrate/01_add_attachment_to_users.rb" with:
12
- """
13
- class AddAttachmentToUsers < ActiveRecord::Migration
14
- def self.up
15
- create_table :users do |t|
16
- t.has_attached_file :avatar
17
- end
18
- end
8
+ Given I run a paperclip migration to add a paperclip "attach" to the "User" model
19
9
 
20
- def self.down
21
- drop_attached_file :users, :avatar
22
- end
23
- end
24
- """
25
10
  And I run a migration
26
- Then I should have attachment columns for "avatar"
11
+ Then I should have attachment columns for "attach"
27
12
 
28
13
  When I rollback a migration
29
- Then I should not have attachment columns for "avatar"
14
+ Then I should not have attachment columns for "attach"
30
15
 
31
16
  Scenario: New syntax with create_table
32
- When I write to "db/migrate/01_add_attachment_to_users.rb" with:
33
- """
34
- class AddAttachmentToUsers < ActiveRecord::Migration
35
- def self.up
36
- create_table :users do |t|
37
- t.attachment :avatar
38
- end
39
- end
40
- end
41
- """
17
+ Given I run a paperclip migration to add a paperclip "attach" to the "User" model
18
+
42
19
  And I run a migration
43
- Then I should have attachment columns for "avatar"
20
+ Then I should have attachment columns for "attach"
44
21
 
45
22
  Scenario: New syntax outside of create_table
46
- When I write to "db/migrate/01_create_users.rb" with:
47
- """
48
- class CreateUsers < ActiveRecord::Migration
49
- def self.up
50
- create_table :users
51
- end
52
- end
53
- """
54
- And I write to "db/migrate/02_add_attachment_to_users.rb" with:
55
- """
56
- class AddAttachmentToUsers < ActiveRecord::Migration
57
- def self.up
58
- add_attachment :users, :avatar
59
- end
23
+ Given I run a paperclip migration to add a paperclip "attachment_sample" to the "User" model
60
24
 
61
- def self.down
62
- remove_attachment :users, :avatar
63
- end
64
- end
65
- """
66
25
  And I run a migration
67
- Then I should have attachment columns for "avatar"
26
+ Then I should have attachment columns for "attachment_sample"
68
27
 
69
28
  When I rollback a migration
70
- Then I should not have attachment columns for "avatar"
29
+ Then I should not have attachment columns for "attachment_sample"