paperclip 4.2.4 → 5.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.codeclimate.yml +17 -0
- data/.hound.yml +1055 -0
- data/.rubocop.yml +1 -0
- data/.travis.yml +17 -15
- data/Appraisals +4 -16
- data/CONTRIBUTING.md +19 -8
- data/Gemfile +4 -8
- data/LICENSE +1 -1
- data/NEWS +105 -2
- data/README.md +327 -191
- data/RELEASING.md +17 -0
- data/Rakefile +2 -2
- data/UPGRADING +12 -9
- data/features/basic_integration.feature +10 -6
- data/features/migration.feature +0 -24
- data/features/step_definitions/attachment_steps.rb +33 -27
- data/features/step_definitions/html_steps.rb +2 -2
- data/features/step_definitions/rails_steps.rb +39 -38
- data/features/step_definitions/s3_steps.rb +2 -2
- data/features/step_definitions/web_steps.rb +1 -103
- data/features/support/env.rb +1 -0
- data/features/support/file_helpers.rb +2 -2
- data/features/support/paths.rb +1 -1
- data/features/support/rails.rb +0 -24
- data/gemfiles/4.2.gemfile +5 -7
- data/gemfiles/5.0.gemfile +17 -0
- data/lib/paperclip/attachment.rb +32 -20
- data/lib/paperclip/attachment_registry.rb +3 -2
- data/lib/paperclip/callbacks.rb +8 -6
- data/lib/paperclip/content_type_detector.rb +27 -11
- data/lib/paperclip/errors.rb +3 -1
- data/lib/paperclip/file_command_content_type_detector.rb +6 -8
- data/lib/paperclip/geometry_parser_factory.rb +1 -1
- data/lib/paperclip/glue.rb +1 -1
- data/lib/paperclip/has_attached_file.rb +9 -2
- data/lib/paperclip/helpers.rb +14 -10
- data/lib/paperclip/interpolations/plural_cache.rb +6 -5
- data/lib/paperclip/interpolations.rb +19 -14
- data/lib/paperclip/io_adapters/abstract_adapter.rb +26 -3
- data/lib/paperclip/io_adapters/attachment_adapter.rb +10 -5
- data/lib/paperclip/io_adapters/data_uri_adapter.rb +8 -8
- data/lib/paperclip/io_adapters/empty_string_adapter.rb +5 -4
- data/lib/paperclip/io_adapters/file_adapter.rb +12 -6
- data/lib/paperclip/io_adapters/http_url_proxy_adapter.rb +7 -7
- data/lib/paperclip/io_adapters/identity_adapter.rb +12 -6
- data/lib/paperclip/io_adapters/nil_adapter.rb +8 -5
- data/lib/paperclip/io_adapters/registry.rb +6 -2
- data/lib/paperclip/io_adapters/stringio_adapter.rb +9 -6
- data/lib/paperclip/io_adapters/uploaded_file_adapter.rb +10 -6
- data/lib/paperclip/io_adapters/uri_adapter.rb +41 -19
- data/lib/paperclip/matchers/validate_attachment_content_type_matcher.rb +4 -4
- data/lib/paperclip/media_type_spoof_detector.rb +2 -2
- data/lib/paperclip/processor.rb +5 -4
- data/lib/paperclip/rails_environment.rb +25 -0
- data/lib/paperclip/schema.rb +3 -9
- data/lib/paperclip/storage/filesystem.rb +13 -2
- data/lib/paperclip/storage/fog.rb +30 -18
- data/lib/paperclip/storage/s3.rb +92 -65
- data/lib/paperclip/thumbnail.rb +16 -7
- data/lib/paperclip/url_generator.rb +16 -13
- data/lib/paperclip/validators/attachment_size_validator.rb +1 -7
- data/lib/paperclip/validators.rb +1 -1
- data/lib/paperclip/version.rb +3 -1
- data/lib/paperclip.rb +25 -12
- data/lib/tasks/paperclip.rake +33 -3
- data/paperclip.gemspec +17 -14
- data/spec/paperclip/attachment_definitions_spec.rb +1 -1
- data/spec/paperclip/attachment_processing_spec.rb +2 -4
- data/spec/paperclip/attachment_registry_spec.rb +84 -13
- data/spec/paperclip/attachment_spec.rb +130 -39
- data/spec/paperclip/content_type_detector_spec.rb +8 -1
- data/spec/paperclip/file_command_content_type_detector_spec.rb +0 -1
- data/spec/paperclip/geometry_spec.rb +1 -1
- data/spec/paperclip/glue_spec.rb +44 -0
- data/spec/paperclip/has_attached_file_spec.rb +24 -8
- data/spec/paperclip/integration_spec.rb +4 -3
- data/spec/paperclip/interpolations_spec.rb +16 -13
- data/spec/paperclip/io_adapters/abstract_adapter_spec.rb +47 -23
- data/spec/paperclip/io_adapters/attachment_adapter_spec.rb +6 -3
- data/spec/paperclip/io_adapters/data_uri_adapter_spec.rb +7 -1
- data/spec/paperclip/io_adapters/file_adapter_spec.rb +6 -3
- data/spec/paperclip/io_adapters/http_url_proxy_adapter_spec.rb +26 -6
- data/spec/paperclip/io_adapters/identity_adapter_spec.rb +1 -1
- data/spec/paperclip/io_adapters/registry_spec.rb +2 -2
- data/spec/paperclip/io_adapters/stringio_adapter_spec.rb +5 -1
- data/spec/paperclip/io_adapters/uploaded_file_adapter_spec.rb +5 -5
- data/spec/paperclip/io_adapters/uri_adapter_spec.rb +77 -7
- data/spec/paperclip/matchers/validate_attachment_content_type_matcher_spec.rb +10 -0
- data/spec/paperclip/media_type_spoof_detector_spec.rb +28 -5
- data/spec/paperclip/paperclip_spec.rb +3 -28
- data/spec/paperclip/plural_cache_spec.rb +17 -16
- data/spec/paperclip/rails_environment_spec.rb +33 -0
- data/spec/paperclip/storage/fog_spec.rb +58 -3
- data/spec/paperclip/storage/s3_live_spec.rb +20 -14
- data/spec/paperclip/storage/s3_spec.rb +398 -213
- data/spec/paperclip/tempfile_factory_spec.rb +4 -0
- data/spec/paperclip/tempfile_spec.rb +35 -0
- data/spec/paperclip/thumbnail_spec.rb +51 -32
- data/spec/paperclip/url_generator_spec.rb +55 -44
- data/spec/paperclip/validators/attachment_size_validator_spec.rb +26 -20
- data/spec/paperclip/validators_spec.rb +5 -5
- data/spec/spec_helper.rb +8 -1
- data/spec/support/assertions.rb +12 -1
- data/spec/support/conditional_filter_helper.rb +5 -0
- data/spec/support/fake_model.rb +4 -0
- data/spec/support/fixtures/empty.xlsx +0 -0
- data/spec/support/matchers/have_column.rb +11 -2
- data/spec/support/mock_attachment.rb +2 -0
- data/spec/support/mock_url_generator_builder.rb +2 -2
- data/spec/support/model_reconstruction.rb +9 -1
- data/spec/support/reporting.rb +11 -0
- metadata +105 -164
- data/RUNNING_TESTS.md +0 -4
- data/cucumber/paperclip_steps.rb +0 -6
- data/gemfiles/3.2.gemfile +0 -19
- data/gemfiles/4.0.gemfile +0 -19
- data/gemfiles/4.1.gemfile +0 -19
- data/lib/paperclip/locales/de.yml +0 -18
- data/lib/paperclip/locales/es.yml +0 -18
- data/lib/paperclip/locales/ja.yml +0 -18
- data/lib/paperclip/locales/pt-BR.yml +0 -18
- data/lib/paperclip/locales/zh-CN.yml +0 -18
- data/lib/paperclip/locales/zh-HK.yml +0 -18
- data/lib/paperclip/locales/zh-TW.yml +0 -18
- data/spec/support/mock_model.rb +0 -2
- data/spec/support/rails_helpers.rb +0 -7
data/.rubocop.yml
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
inherit_from: .hound.yml
|
data/.travis.yml
CHANGED
@@ -1,23 +1,25 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
- jruby-19mode
|
4
|
-
- rbx-2
|
5
|
-
- 2.0.0
|
6
|
-
- 2.1.1
|
1
|
+
language: ruby
|
2
|
+
sudo: false
|
7
3
|
|
8
|
-
|
9
|
-
-
|
4
|
+
rvm:
|
5
|
+
- 2.1
|
6
|
+
- 2.2
|
7
|
+
- 2.3
|
8
|
+
- 2.4
|
10
9
|
|
11
|
-
before_script: "sudo ntpdate -ub ntp.ubuntu.com pool.ntp.org; true"
|
12
10
|
script: "bundle exec rake clean spec cucumber"
|
13
11
|
|
12
|
+
addons:
|
13
|
+
apt:
|
14
|
+
packages:
|
15
|
+
- ghostscript
|
16
|
+
|
14
17
|
gemfile:
|
15
|
-
- gemfiles/
|
16
|
-
- gemfiles/
|
17
|
-
- gemfiles/4.1.gemfile
|
18
|
+
- gemfiles/4.2.gemfile
|
19
|
+
- gemfiles/5.0.gemfile
|
18
20
|
|
19
21
|
matrix:
|
20
22
|
fast_finish: true
|
21
|
-
|
22
|
-
-
|
23
|
-
|
23
|
+
exclude:
|
24
|
+
- gemfile: gemfiles/5.0.gemfile
|
25
|
+
rvm: 2.1
|
data/Appraisals
CHANGED
@@ -1,19 +1,7 @@
|
|
1
|
-
appraise "
|
2
|
-
gem "rails", "~>
|
3
|
-
gem "paperclip", :path => "../"
|
4
|
-
end
|
5
|
-
|
6
|
-
appraise "4.0" do
|
7
|
-
gem "rails", "~> 4.0.0"
|
8
|
-
gem "paperclip", :path => "../"
|
9
|
-
end
|
10
|
-
|
11
|
-
appraise "4.1" do
|
12
|
-
gem "rails", "~> 4.1.0"
|
13
|
-
gem "paperclip", :path => "../"
|
1
|
+
appraise "4.2" do
|
2
|
+
gem "rails", "~> 4.2.0"
|
14
3
|
end
|
15
4
|
|
16
|
-
appraise "
|
17
|
-
gem "rails", "~>
|
18
|
-
gem "paperclip", :path => "../"
|
5
|
+
appraise "5.0" do
|
6
|
+
gem "rails", "~> 5.0.0"
|
19
7
|
end
|
data/CONTRIBUTING.md
CHANGED
@@ -1,20 +1,31 @@
|
|
1
1
|
Contributing
|
2
2
|
============
|
3
3
|
|
4
|
-
We love pull requests.
|
4
|
+
We love pull requests from everyone. By participating in this project, you agree
|
5
|
+
to abide by the thoughtbot [code of conduct].
|
6
|
+
|
7
|
+
[code of conduct]: https://thoughtbot.com/open-source-code-of-conduct
|
8
|
+
|
9
|
+
Here's a quick guide for contributing:
|
5
10
|
|
6
11
|
1. Fork the repo.
|
7
12
|
|
8
|
-
|
9
|
-
|
13
|
+
1. Make sure you have ImageMagick and Ghostscript installed. See [this section]
|
14
|
+
(./README.md#image-processor) of the README.
|
10
15
|
|
11
|
-
|
16
|
+
1. Run the tests. We only take pull requests with passing tests, and it's great
|
17
|
+
to know that you have a clean slate: `bundle && bundle exec rake`
|
18
|
+
|
19
|
+
1. Add a test for your change. Only refactoring and documentation changes
|
12
20
|
require no new tests. If you are adding functionality or fixing a bug, we need
|
13
21
|
a test!
|
14
22
|
|
15
|
-
|
23
|
+
1. Make the test pass.
|
24
|
+
|
25
|
+
1. Mention how your changes affect the project to other developers and users in
|
26
|
+
the `NEWS.md` file.
|
16
27
|
|
17
|
-
|
28
|
+
1. Push to your fork and submit a pull request.
|
18
29
|
|
19
30
|
At this point you're waiting on us. We like to at least comment on, if not
|
20
31
|
accept, pull requests within seven business days (most of the work on Paperclip
|
@@ -43,14 +54,14 @@ will be asked to rewrite them before we'll accept.
|
|
43
54
|
### Bootstrapping your test suite:
|
44
55
|
|
45
56
|
bundle install
|
46
|
-
bundle exec
|
57
|
+
bundle exec appraisal install
|
47
58
|
|
48
59
|
This will install all the required gems that requires to test against each
|
49
60
|
version of Rails, which defined in `gemfiles/*.gemfile`.
|
50
61
|
|
51
62
|
### To run a full test suite:
|
52
63
|
|
53
|
-
bundle exec rake
|
64
|
+
bundle exec appraisal rake
|
54
65
|
|
55
66
|
This will run RSpec and Cucumber against all version of Rails
|
56
67
|
|
data/Gemfile
CHANGED
@@ -3,18 +3,14 @@ source "https://rubygems.org"
|
|
3
3
|
gemspec
|
4
4
|
|
5
5
|
gem 'sqlite3', '~> 1.3.8', :platforms => :ruby
|
6
|
-
|
7
|
-
gem 'jruby-openssl', :platforms => :jruby
|
8
|
-
gem 'activerecord-jdbcsqlite3-adapter', :platforms => :jruby
|
9
|
-
|
10
|
-
gem 'rubysl', :platforms => :rbx
|
11
|
-
gem 'racc', :platforms => :rbx
|
12
|
-
|
13
6
|
gem 'pry'
|
14
7
|
|
15
8
|
# Hinting at development dependencies
|
16
9
|
# Prevents bundler from taking a long-time to resolve
|
17
10
|
group :development, :test do
|
18
|
-
gem '
|
11
|
+
gem 'activerecord-import'
|
12
|
+
gem 'mime-types'
|
19
13
|
gem 'builder'
|
14
|
+
gem 'rubocop', require: false
|
15
|
+
gem 'rspec'
|
20
16
|
end
|
data/LICENSE
CHANGED
@@ -3,7 +3,7 @@ LICENSE
|
|
3
3
|
|
4
4
|
The MIT License
|
5
5
|
|
6
|
-
Copyright (c) 2008-
|
6
|
+
Copyright (c) 2008-2016 Jon Yurek and thoughtbot, inc.
|
7
7
|
|
8
8
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
9
9
|
of this software and associated documentation files (the "Software"), to deal
|
data/NEWS
CHANGED
@@ -1,4 +1,107 @@
|
|
1
|
-
|
1
|
+
5.2.0 (2018-01-23):
|
2
|
+
|
3
|
+
* Security: Remove the automatic loading of URI adapters. Some of these
|
4
|
+
adapters can be specially crafted to expose your network topology. (#2435)
|
5
|
+
* Bugfix: The rake task no longer rescues `Exception`. (#2476)
|
6
|
+
* Bugfix: Handle malformed `Content-Disposition` headers (#2283)
|
7
|
+
* Bugfix: The `:only_process` option works when passed a lambda again. (#2289)
|
8
|
+
* Improvement: Added `:use_accelerate_endpoint` option when using S3 to enable
|
9
|
+
[Amazon S3 Transfer Acceleration](http://docs.aws.amazon.com/AmazonS3/latest/dev/transfer-acceleration.html)
|
10
|
+
(#2291)
|
11
|
+
* Improvement: Make the fingerprint digest configurable per attachment. The
|
12
|
+
default remains MD5. Making this configurable means it can change in a future
|
13
|
+
version because it is not considered secure anymore against intentional file
|
14
|
+
corruption. For more info, see https://en.wikipedia.org/wiki/MD5#Security
|
15
|
+
|
16
|
+
You can change the digest used for an attachment by adding the
|
17
|
+
`:adapter_options` parameter to the `has_attached_file` options like this:
|
18
|
+
`has_attached_file :avatar, adapter_options: { hash_digest: Digest::SHA256 }`
|
19
|
+
|
20
|
+
Use the rake task to regenerate fingerprints with the new digest for a given
|
21
|
+
class. Note that this does **not** check the file integrity using the old
|
22
|
+
fingerprint. Run the following command to regenerate fingerprints for all
|
23
|
+
User attachments:
|
24
|
+
`CLASS=User rake paperclip:refresh:fingerprints`
|
25
|
+
You can optionally limit the attachment that will be processed, e.g:
|
26
|
+
`CLASS=User ATTACHMENT=avatar rake paperclip:refresh:fingerprints` (#2229)
|
27
|
+
* Improvement: The new `frame_index` option on the thumbnail processor allows
|
28
|
+
you to select a specific frame from an animated upload to use as a thumbnail.
|
29
|
+
Initial support is for mkv, avi, MP4, mov, MPEG, and GIF. (#2155)
|
30
|
+
* Improvement: Instead of copying files, use hard links. This is an
|
31
|
+
optimization. (#2120)
|
32
|
+
* Improvement: S3 storage option `:s3_prefixes_in_alias`. (#2287)
|
33
|
+
* Improvement: Fog option `:fog_public` can be a lambda. (#2302)
|
34
|
+
* Improvement: One fewer warning on JRuby. (#2352)
|
35
|
+
|
36
|
+
5.1.0 (2016-08-19):
|
37
|
+
|
38
|
+
* Add default `content_type_detector` to `UploadedFileAdapter` (#2270)
|
39
|
+
* Default S3 protocol to empty string (#2038)
|
40
|
+
* Don't write original file if it wasn't reprocessed (#1993)
|
41
|
+
* Disallow trailing newlines in regular expressions (#2266)
|
42
|
+
* Support for readbyte in Paperclip attachments (#2034)
|
43
|
+
* (port from 4.3) Uri io adapter uses the content-disposition filename (#2250)
|
44
|
+
* General refactors and documentation improvements
|
45
|
+
|
46
|
+
5.0.0 (2016-07-01):
|
47
|
+
|
48
|
+
* Improvement: Add `read_timeout` configuration for URI Adapter download_content method.
|
49
|
+
* README adjustments for Ruby beginners (add links, elucidate model in Quick Start)
|
50
|
+
* Bugfix: Now it's possible to save images from URLs with special characters [#1932]
|
51
|
+
* Bugfix: Return false when file to copy is not present in cloud storage [#2173]
|
52
|
+
* Automatically close file while checking mime type [#2016]
|
53
|
+
* Add `read_timeout` option to `UriAdapter#download_content` method [#2232]
|
54
|
+
* Fix a nil error in content type validation matcher [#1910]
|
55
|
+
* Documentation improvements
|
56
|
+
|
57
|
+
5.0.0.beta2 (2016-04-01):
|
58
|
+
|
59
|
+
* Bugfix: Dynamic fog directory option is now respected
|
60
|
+
* Bugfix: Fixes cocaine duplicated paths [#2169]
|
61
|
+
* Removal of dead code (older versions of Rails and AWS SDK)
|
62
|
+
* README adjustments
|
63
|
+
|
64
|
+
5.0.0.beta1 (2016-03-13):
|
65
|
+
|
66
|
+
* Bug Fix: megabytes of mime-types info in logs when a spoofed media type is detected.
|
67
|
+
* Drop support to end-of-life'd ruby 2.0.
|
68
|
+
* Drop support for end-of-life'd Rails 3.2 and 4.1
|
69
|
+
* Drop support for AWS v1
|
70
|
+
* Remove tests for JRuby and Rubinius from Travis CI (they were failing)
|
71
|
+
* Improvement: Add `fog_options` configuration to send options to fog when
|
72
|
+
storing files.
|
73
|
+
* Extracted repository for locales only: https://github.com/thoughtbot/paperclip-i18n
|
74
|
+
* Bugfix: Original file could be unlinked during `post_process_style`, producing failures
|
75
|
+
* Bugfix for image magick scaling images up
|
76
|
+
* Memory consumption improvements
|
77
|
+
* `url` on a unpersisted record returns `default_url` rather than `nil`
|
78
|
+
* Improvement: aws-sdk v2 support
|
79
|
+
https://github.com/thoughtbot/paperclip/pull/1903
|
80
|
+
|
81
|
+
If your Gemfile contains aws-sdk (>= 2.0.0) and aws-sdk-v1, paperclip will use
|
82
|
+
aws-sdk v2. With aws-sdk v2, S3 storage requires you to set the s3_region.
|
83
|
+
s3_region may be nested in s3_credentials, and (if not nested in
|
84
|
+
s3_credentials) it may be a Proc.
|
85
|
+
|
86
|
+
4.3
|
87
|
+
|
88
|
+
See patch versions in v4.3 NEWS:
|
89
|
+
https://github.com/thoughtbot/paperclip/blob/v4.3/NEWS
|
90
|
+
|
91
|
+
4.3.0 (2015-06-18):
|
92
|
+
|
93
|
+
* Improvement: Update aws-sdk and cucumber gem versions.
|
94
|
+
* Improvement: Add `length` alias for `size` method in AbstractAdapter.
|
95
|
+
* Improvement: Removed some cruft
|
96
|
+
* Improvement: deep_merge! Attachment definitions
|
97
|
+
* Improvement: Switch to mimemagic gem for content-type detection
|
98
|
+
* Improvement: Allows multiple content types for spoof detector
|
99
|
+
* Bug Fix: Don't assume we have Rails.env if we have Rails
|
100
|
+
* Performance: Decrease Memory footprint
|
101
|
+
* Ruby Versioning: Drop support for 1.9.3 (EOL'ed)
|
102
|
+
* Rails Versioning: Drop support for 4.0.0 (EOL'ed)
|
103
|
+
|
104
|
+
4.2.4 (2015-06-05):
|
2
105
|
|
3
106
|
* Rollback backwards incompatible change, allowing paperclip to run on
|
4
107
|
Ruby >= 1.9.2.
|
@@ -22,7 +125,7 @@
|
|
22
125
|
* Improvement: Better escaping for characters in URLs
|
23
126
|
* Improvement: Honor `fog_credentials[:scheme]`
|
24
127
|
* Improvement: Also look for custom processors in lib/paperclip
|
25
|
-
* Improvement: id partitioning for string IDs works
|
128
|
+
* Improvement: id partitioning for string IDs works like integer id
|
26
129
|
* Improvement: Can pass options to DB adapters in migrations
|
27
130
|
* Improvement: Update expiring_url creation for later versions of fog
|
28
131
|
* Improvement: `path` can be a Proc in S3 attachments
|