paperclip 5.1.0 → 5.2.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/.codeclimate.yml +17 -0
- data/.hound.yml +5 -16
- data/.travis.yml +14 -15
- data/Appraisals +3 -23
- data/Gemfile +1 -0
- data/NEWS +36 -1
- data/README.md +58 -10
- data/Rakefile +1 -1
- data/UPGRADING +1 -1
- data/features/step_definitions/attachment_steps.rb +6 -6
- data/features/step_definitions/rails_steps.rb +29 -22
- data/features/step_definitions/s3_steps.rb +1 -1
- data/features/support/env.rb +1 -0
- data/features/support/paths.rb +1 -1
- data/features/support/rails.rb +0 -24
- data/gemfiles/{4.2.awsv2.0.gemfile → 4.2.gemfile} +1 -1
- data/gemfiles/{5.0.awsv2.1.gemfile → 5.0.gemfile} +2 -2
- data/lib/paperclip.rb +12 -10
- data/lib/paperclip/attachment.rb +10 -4
- data/lib/paperclip/io_adapters/abstract_adapter.rb +24 -2
- 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 +9 -5
- data/lib/paperclip/io_adapters/uri_adapter.rb +13 -11
- data/lib/paperclip/storage/filesystem.rb +13 -2
- data/lib/paperclip/storage/fog.rb +7 -4
- data/lib/paperclip/storage/s3.rb +31 -3
- data/lib/paperclip/thumbnail.rb +14 -4
- data/lib/paperclip/version.rb +1 -1
- data/lib/tasks/paperclip.rake +17 -3
- data/paperclip.gemspec +3 -3
- data/spec/paperclip/attachment_spec.rb +39 -8
- data/spec/paperclip/io_adapters/abstract_adapter_spec.rb +44 -21
- 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 +2 -2
- data/spec/paperclip/io_adapters/http_url_proxy_adapter_spec.rb +6 -1
- 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 +1 -1
- data/spec/paperclip/io_adapters/uploaded_file_adapter_spec.rb +3 -3
- data/spec/paperclip/io_adapters/uri_adapter_spec.rb +6 -1
- data/spec/paperclip/storage/fog_spec.rb +16 -0
- data/spec/paperclip/storage/s3_live_spec.rb +12 -10
- data/spec/paperclip/storage/s3_spec.rb +85 -4
- data/spec/paperclip/tempfile_spec.rb +35 -0
- data/spec/paperclip/thumbnail_spec.rb +35 -32
- data/spec/spec_helper.rb +3 -1
- data/spec/support/assertions.rb +5 -1
- data/spec/support/conditional_filter_helper.rb +5 -0
- metadata +31 -135
- data/gemfiles/4.2.awsv2.1.gemfile +0 -17
- data/gemfiles/4.2.awsv2.gemfile +0 -20
- data/gemfiles/5.0.awsv2.0.gemfile +0 -17
- data/gemfiles/5.0.awsv2.gemfile +0 -20
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA1:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: 569debc832514cb262986c31782d4590065f944b
         | 
| 4 | 
            +
              data.tar.gz: b65dbae4e73cddd0c685e0c1bd4fc101ef09d251
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: f0890bb495c49f763d1765015e5e7818c3d7ae6e50fbb33281226c6ccf3a316dd39b6c7e0df20fbe559522fb0c1fdc8b61c824fd954a8c5699920dcd2db88992
         | 
| 7 | 
            +
              data.tar.gz: 7913049f0c5cbdd2b3912dfea1121fce81ea002bcdee5924ad2e48c2fc03fa5dc391922666d48310957444123d495a6e6266b6433fb51c7b512980322d527485
         | 
    
        data/.codeclimate.yml
    ADDED
    
    
    
        data/.hound.yml
    CHANGED
    
    | @@ -20,7 +20,8 @@ AllCops: | |
| 20 20 | 
             
                - "db/schema.rb"
         | 
| 21 21 | 
             
                - 'vendor/**/*'
         | 
| 22 22 | 
             
                - 'gemfiles/vendor/**/*'
         | 
| 23 | 
            -
               | 
| 23 | 
            +
              Rails:
         | 
| 24 | 
            +
                Enabled: false
         | 
| 24 25 | 
             
              DisplayCopNames: false
         | 
| 25 26 | 
             
              StyleGuideCopsOnly: false
         | 
| 26 27 | 
             
            Style/AccessModifierIndentation:
         | 
| @@ -434,7 +435,7 @@ Style/TrailingBlankLines: | |
| 434 435 | 
             
              SupportedStyles:
         | 
| 435 436 | 
             
              - final_newline
         | 
| 436 437 | 
             
              - final_blank_line
         | 
| 437 | 
            -
            Style/ | 
| 438 | 
            +
            Style/TrailingCommaInLiteral:
         | 
| 438 439 | 
             
              Description: Checks for trailing comma in parameter lists and literals.
         | 
| 439 440 | 
             
              StyleGuide: https://github.com/bbatsov/ruby-style-guide#no-trailing-array-commas
         | 
| 440 441 | 
             
              Enabled: false
         | 
| @@ -560,11 +561,6 @@ Rails/ActionFilter: | |
| 560 561 | 
             
              - filter
         | 
| 561 562 | 
             
              Include:
         | 
| 562 563 | 
             
              - app/controllers/**/*.rb
         | 
| 563 | 
            -
            Rails/DefaultScope:
         | 
| 564 | 
            -
              Description: Checks if the argument passed to default_scope is a block.
         | 
| 565 | 
            -
              Enabled: true
         | 
| 566 | 
            -
              Include:
         | 
| 567 | 
            -
              - app/models/**/*.rb
         | 
| 568 564 | 
             
            Rails/HasAndBelongsToMany:
         | 
| 569 565 | 
             
              Description: Prefer has_many :through to has_and_belongs_to_many.
         | 
| 570 566 | 
             
              Enabled: true
         | 
| @@ -685,10 +681,6 @@ Style/DefWithParentheses: | |
| 685 681 | 
             
              Description: Use def with parentheses when there are arguments.
         | 
| 686 682 | 
             
              StyleGuide: https://github.com/bbatsov/ruby-style-guide#method-parens
         | 
| 687 683 | 
             
              Enabled: true
         | 
| 688 | 
            -
            Style/DeprecatedHashMethods:
         | 
| 689 | 
            -
              Description: Checks for use of deprecated Hash methods.
         | 
| 690 | 
            -
              StyleGuide: https://github.com/bbatsov/ruby-style-guide#hash-key
         | 
| 691 | 
            -
              Enabled: false
         | 
| 692 684 | 
             
            Style/Documentation:
         | 
| 693 685 | 
             
              Description: Document classes and non-namespace modules.
         | 
| 694 686 | 
             
              Enabled: false
         | 
| @@ -840,7 +832,7 @@ Style/SelfAssignment: | |
| 840 832 | 
             
                used.
         | 
| 841 833 | 
             
              StyleGuide: https://github.com/bbatsov/ruby-style-guide#self-assignment
         | 
| 842 834 | 
             
              Enabled: false
         | 
| 843 | 
            -
            Style/ | 
| 835 | 
            +
            Style/SpaceBeforeFirstArg:
         | 
| 844 836 | 
             
              Description: Checks that exactly one space is used between a method name and the
         | 
| 845 837 | 
             
                first argument for method calls without parentheses.
         | 
| 846 838 | 
             
              Enabled: true
         | 
| @@ -852,7 +844,7 @@ Style/SpaceAfterComma: | |
| 852 844 | 
             
              Description: Use spaces after commas.
         | 
| 853 845 | 
             
              StyleGuide: https://github.com/bbatsov/ruby-style-guide#spaces-operators
         | 
| 854 846 | 
             
              Enabled: true
         | 
| 855 | 
            -
            Style/ | 
| 847 | 
            +
            Style/SpaceAroundKeyword:
         | 
| 856 848 | 
             
              Description: Use spaces after if/elsif/unless/while/until/case/when.
         | 
| 857 849 | 
             
              Enabled: true
         | 
| 858 850 | 
             
            Style/SpaceAfterMethodName:
         | 
| @@ -881,9 +873,6 @@ Style/SpaceAroundOperators: | |
| 881 873 | 
             
              Description: Use spaces around operators.
         | 
| 882 874 | 
             
              StyleGuide: https://github.com/bbatsov/ruby-style-guide#spaces-operators
         | 
| 883 875 | 
             
              Enabled: true
         | 
| 884 | 
            -
            Style/SpaceBeforeModifierKeyword:
         | 
| 885 | 
            -
              Description: Put a space before the modifier keyword.
         | 
| 886 | 
            -
              Enabled: true
         | 
| 887 876 | 
             
            Style/SpaceInsideBrackets:
         | 
| 888 877 | 
             
              Description: No spaces after [ or before ].
         | 
| 889 878 | 
             
              StyleGuide: https://github.com/bbatsov/ruby-style-guide#no-spaces-braces
         | 
    
        data/.travis.yml
    CHANGED
    
    | @@ -1,26 +1,25 @@ | |
| 1 | 
            +
            language: ruby
         | 
| 2 | 
            +
            sudo: false
         | 
| 3 | 
            +
             | 
| 1 4 | 
             
            rvm:
         | 
| 2 5 | 
             
              - 2.1
         | 
| 3 | 
            -
              - 2.2 | 
| 6 | 
            +
              - 2.2
         | 
| 7 | 
            +
              - 2.3
         | 
| 8 | 
            +
              - 2.4
         | 
| 4 9 |  | 
| 5 10 | 
             
            script: "bundle exec rake clean spec cucumber"
         | 
| 6 11 |  | 
| 12 | 
            +
            addons:
         | 
| 13 | 
            +
              apt:
         | 
| 14 | 
            +
                packages:
         | 
| 15 | 
            +
                - ghostscript
         | 
| 16 | 
            +
             | 
| 7 17 | 
             
            gemfile:
         | 
| 8 | 
            -
              - gemfiles/4.2. | 
| 9 | 
            -
              - gemfiles/ | 
| 10 | 
            -
              - gemfiles/5.0.awsv2.0.gemfile
         | 
| 11 | 
            -
              - gemfiles/5.0.awsv2.1.gemfile
         | 
| 18 | 
            +
              - gemfiles/4.2.gemfile
         | 
| 19 | 
            +
              - gemfiles/5.0.gemfile
         | 
| 12 20 |  | 
| 13 21 | 
             
            matrix:
         | 
| 14 22 | 
             
              fast_finish: true
         | 
| 15 23 | 
             
              exclude:
         | 
| 16 | 
            -
                - gemfile: gemfiles/5.0. | 
| 17 | 
            -
                  rvm: 2.0
         | 
| 18 | 
            -
                - gemfile: gemfiles/5.0.awsv2.1.gemfile
         | 
| 19 | 
            -
                  rvm: 2.0
         | 
| 20 | 
            -
                - gemfile: gemfiles/5.0.awsv2.0.gemfile
         | 
| 24 | 
            +
                - gemfile: gemfiles/5.0.gemfile
         | 
| 21 25 | 
             
                  rvm: 2.1
         | 
| 22 | 
            -
                - gemfile: gemfiles/5.0.awsv2.1.gemfile
         | 
| 23 | 
            -
                  rvm: 2.1
         | 
| 24 | 
            -
             | 
| 25 | 
            -
            sudo: false
         | 
| 26 | 
            -
            cache: bundler
         | 
    
        data/Appraisals
    CHANGED
    
    | @@ -1,27 +1,7 @@ | |
| 1 | 
            -
            appraise "4.2 | 
| 1 | 
            +
            appraise "4.2" do
         | 
| 2 2 | 
             
              gem "rails", "~> 4.2.0"
         | 
| 3 | 
            -
              gem "aws-sdk", "~> 2.0.0"
         | 
| 4 3 | 
             
            end
         | 
| 5 4 |  | 
| 6 | 
            -
            appraise " | 
| 7 | 
            -
              gem "rails", "~>  | 
| 8 | 
            -
              gem "aws-sdk", "~> 2.1.0"
         | 
| 9 | 
            -
             | 
| 10 | 
            -
              group :development, :test do
         | 
| 11 | 
            -
                gem 'mime-types', '>= 1.16', '< 4'
         | 
| 12 | 
            -
              end
         | 
| 13 | 
            -
            end
         | 
| 14 | 
            -
             | 
| 15 | 
            -
            appraise "5.0.awsv2.0" do
         | 
| 16 | 
            -
              gem "rails", "5.0.0.beta3"
         | 
| 17 | 
            -
              gem "aws-sdk", "~> 2.0.0"
         | 
| 18 | 
            -
             | 
| 19 | 
            -
              group :development, :test do
         | 
| 20 | 
            -
                gem 'mime-types', '>= 1.16', '< 4'
         | 
| 21 | 
            -
              end
         | 
| 22 | 
            -
            end
         | 
| 23 | 
            -
             | 
| 24 | 
            -
            appraise "5.0.awsv2.1" do
         | 
| 25 | 
            -
              gem "rails", "5.0.0.beta3"
         | 
| 26 | 
            -
              gem "aws-sdk", "~> 2.1.0"
         | 
| 5 | 
            +
            appraise "5.0" do
         | 
| 6 | 
            +
              gem "rails", "~> 5.0.0"
         | 
| 27 7 | 
             
            end
         | 
    
        data/Gemfile
    CHANGED
    
    
    
        data/NEWS
    CHANGED
    
    | @@ -1,4 +1,39 @@ | |
| 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):
         | 
| 2 37 |  | 
| 3 38 | 
             
            * Add default `content_type_detector` to `UploadedFileAdapter` (#2270)
         | 
| 4 39 | 
             
            * Default S3 protocol to empty string (#2038)
         | 
    
        data/README.md
    CHANGED
    
    | @@ -17,7 +17,6 @@ https://github.com/thoughtbot/paperclip/releases | |
| 17 17 | 
             
            <!-- START doctoc generated TOC please keep comment here to allow auto update -->
         | 
| 18 18 | 
             
            <!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
         | 
| 19 19 |  | 
| 20 | 
            -
             | 
| 21 20 | 
             
            - [Requirements](#requirements)
         | 
| 22 21 | 
             
              - [Ruby and Rails](#ruby-and-rails)
         | 
| 23 22 | 
             
              - [Image Processor](#image-processor)
         | 
| @@ -30,6 +29,7 @@ https://github.com/thoughtbot/paperclip/releases | |
| 30 29 | 
             
              - [Edit and New Views with Simple Form](#edit-and-new-views-with-simple-form)
         | 
| 31 30 | 
             
              - [Controller](#controller)
         | 
| 32 31 | 
             
              - [View Helpers](#view-helpers)
         | 
| 32 | 
            +
              - [Checking a File Exists](#checking-a-file-exists)
         | 
| 33 33 | 
             
              - [Deleting an Attachment](#deleting-an-attachment)
         | 
| 34 34 | 
             
            - [Usage](#usage)
         | 
| 35 35 | 
             
            - [Validations](#validations)
         | 
| @@ -39,14 +39,15 @@ https://github.com/thoughtbot/paperclip/releases | |
| 39 39 | 
             
            - [Migrations](#migrations-1)
         | 
| 40 40 | 
             
              - [Add Attachment Column To A Table](#add-attachment-column-to-a-table)
         | 
| 41 41 | 
             
              - [Schema Definition](#schema-definition)
         | 
| 42 | 
            -
              - [Vintage  | 
| 42 | 
            +
              - [Vintage Syntax](#vintage-syntax)
         | 
| 43 43 | 
             
            - [Storage](#storage)
         | 
| 44 44 | 
             
              - [Understanding Storage](#understanding-storage)
         | 
| 45 | 
            +
            - [IO Adapters](#io-adapters)
         | 
| 45 46 | 
             
            - [Post Processing](#post-processing)
         | 
| 46 47 | 
             
            - [Custom Attachment Processors](#custom-attachment-processors)
         | 
| 47 48 | 
             
            - [Events](#events)
         | 
| 48 49 | 
             
            - [URI Obfuscation](#uri-obfuscation)
         | 
| 49 | 
            -
            - [ | 
| 50 | 
            +
            - [Checksum / Fingerprint](#checksum--fingerprint)
         | 
| 50 51 | 
             
            - [File Preservation for Soft-Delete](#file-preservation-for-soft-delete)
         | 
| 51 52 | 
             
            - [Dynamic Configuration](#dynamic-configuration)
         | 
| 52 53 | 
             
              - [Dynamic Styles:](#dynamic-styles)
         | 
| @@ -260,7 +261,7 @@ end | |
| 260 261 | 
             
            <%= image_tag @user.avatar.url(:thumb) %>
         | 
| 261 262 | 
             
            ```
         | 
| 262 263 |  | 
| 263 | 
            -
            ### Checking a  | 
| 264 | 
            +
            ### Checking a File Exists
         | 
| 264 265 |  | 
| 265 266 | 
             
            There are two methods for checking if a file exists:
         | 
| 266 267 |  | 
| @@ -549,7 +550,7 @@ class AddAttachmentColumnsToUsers < ActiveRecord::Migration | |
| 549 550 | 
             
            end
         | 
| 550 551 | 
             
            ```
         | 
| 551 552 |  | 
| 552 | 
            -
            ### Vintage  | 
| 553 | 
            +
            ### Vintage Syntax
         | 
| 553 554 |  | 
| 554 555 | 
             
            Vintage syntax (such as `t.has_attached_file` and `drop_attached_file`) is still supported in
         | 
| 555 556 | 
             
            Paperclip 3.x, but you're advised to update those migration files to use this new syntax.
         | 
| @@ -591,7 +592,7 @@ You may also choose to store your files using Amazon's S3 service. To do so, inc | |
| 591 592 | 
             
            the `aws-sdk` gem in your Gemfile:
         | 
| 592 593 |  | 
| 593 594 | 
             
            ```ruby
         | 
| 594 | 
            -
            gem 'aws-sdk', ' | 
| 595 | 
            +
            gem 'aws-sdk', '~> 2.3.0'
         | 
| 595 596 | 
             
            ```
         | 
| 596 597 |  | 
| 597 598 | 
             
            And then you can specify using S3 from `has_attached_file`.
         | 
| @@ -607,6 +608,34 @@ variables. | |
| 607 608 |  | 
| 608 609 | 
             
            ---
         | 
| 609 610 |  | 
| 611 | 
            +
            IO Adapters
         | 
| 612 | 
            +
            -----------
         | 
| 613 | 
            +
             | 
| 614 | 
            +
            When a file is uploaded or attached, it can be in one of a few different input
         | 
| 615 | 
            +
            forms, from Rails' UploadedFile object to a StringIO to a Tempfile or even a
         | 
| 616 | 
            +
            simple String that is a URL that points to an image.
         | 
| 617 | 
            +
             | 
| 618 | 
            +
            Paperclip will accept, by default, many of these sources. It also is capable of
         | 
| 619 | 
            +
            handling even more with a little configuration. The IO Adapters that handle
         | 
| 620 | 
            +
            images from non-local sources are not enabled by default. They can be enabled by
         | 
| 621 | 
            +
            adding a line similar to the following into `config/initializers/paperclip.rb`:
         | 
| 622 | 
            +
             | 
| 623 | 
            +
            ```ruby
         | 
| 624 | 
            +
            Paperclip::DataUriAdapter.register
         | 
| 625 | 
            +
            ```
         | 
| 626 | 
            +
             | 
| 627 | 
            +
            It's best to only enable a remote-loading adapter if you need it. Otherwise
         | 
| 628 | 
            +
            there's a chance that someone can gain insight into your internal network
         | 
| 629 | 
            +
            structure using it as a vector.
         | 
| 630 | 
            +
             | 
| 631 | 
            +
            The following adapters are *not* loaded by default:
         | 
| 632 | 
            +
             | 
| 633 | 
            +
            * `Paperclip::UriAdapter` - which accepts a `URI` instance.
         | 
| 634 | 
            +
            * `Paperclip::HttpUrlProxyAdapter` - which accepts a `http` string.
         | 
| 635 | 
            +
            * `Paperclip::DataUriAdapter` - which accepts a Base64-encoded `data:` string.
         | 
| 636 | 
            +
             | 
| 637 | 
            +
            ---
         | 
| 638 | 
            +
             | 
| 610 639 | 
             
            Post Processing
         | 
| 611 640 | 
             
            ---------------
         | 
| 612 641 |  | 
| @@ -627,6 +656,14 @@ JPGs will remain JPGs). `Paperclip::Thumbnail` uses ImageMagick to process | |
| 627 656 | 
             
            images; [ImageMagick's geometry documentation](http://www.imagemagick.org/script/command-line-processing.php#geometry)
         | 
| 628 657 | 
             
            has more information on the accepted style formats.
         | 
| 629 658 |  | 
| 659 | 
            +
            ImageMagick supports a number of environment variables for controlling its resource limits. For example, you can enforce memory or execution time limits by setting the following variables in your application's process environment:
         | 
| 660 | 
            +
             | 
| 661 | 
            +
            * `MAGICK_MEMORY_LIMIT=128MiB`
         | 
| 662 | 
            +
            * `MAGICK_MAP_LIMIT=64MiB`
         | 
| 663 | 
            +
            * `MAGICK_TIME_LIMIT=30`
         | 
| 664 | 
            +
             | 
| 665 | 
            +
            For a full list of variables and description, see [ImageMagick's resources documentation](http://www.imagemagick.org/script/resources.php).
         | 
| 666 | 
            +
             | 
| 630 667 | 
             
            ---
         | 
| 631 668 |  | 
| 632 669 | 
             
            Custom Attachment Processors
         | 
| @@ -736,10 +773,10 @@ is specified in `:hash_data`. The default value for `:hash_data` is `":class/:at | |
| 736 773 |  | 
| 737 774 | 
             
            For more on this feature, read [the author's own explanation](https://github.com/thoughtbot/paperclip/pull/416)
         | 
| 738 775 |  | 
| 739 | 
            -
             | 
| 776 | 
            +
            Checksum / Fingerprint
         | 
| 740 777 | 
             
            -------
         | 
| 741 778 |  | 
| 742 | 
            -
             | 
| 779 | 
            +
            A checksum of the original file assigned will be placed in the model if it
         | 
| 743 780 | 
             
            has an attribute named fingerprint.  Following the user model migration example
         | 
| 744 781 | 
             
            above, the migration would look like the following:
         | 
| 745 782 |  | 
| @@ -755,6 +792,17 @@ class AddAvatarFingerprintColumnToUser < ActiveRecord::Migration | |
| 755 792 | 
             
            end
         | 
| 756 793 | 
             
            ```
         | 
| 757 794 |  | 
| 795 | 
            +
            The algorithm can be specified using a configuration option; it defaults to MD5
         | 
| 796 | 
            +
            for backwards compatibility with Paperclip 5 and earlier.
         | 
| 797 | 
            +
             | 
| 798 | 
            +
            ```ruby
         | 
| 799 | 
            +
            has_attached_file :some_attachment, adapter_options: { hash_digest: Digest::SHA256 }
         | 
| 800 | 
            +
            ```
         | 
| 801 | 
            +
             | 
| 802 | 
            +
            Run `CLASS=User ATTACHMENT=avatar rake paperclip:refresh:fingerprints` after
         | 
| 803 | 
            +
            changing the digest on existing attachments to update the fingerprints in the
         | 
| 804 | 
            +
            database.
         | 
| 805 | 
            +
             | 
| 758 806 | 
             
            File Preservation for Soft-Delete
         | 
| 759 807 | 
             
            -------
         | 
| 760 808 |  | 
| @@ -984,13 +1032,13 @@ Thank you to all [the contributors](https://github.com/thoughtbot/paperclip/grap | |
| 984 1032 | 
             
            License
         | 
| 985 1033 | 
             
            -------
         | 
| 986 1034 |  | 
| 987 | 
            -
            Paperclip is Copyright © 2008- | 
| 1035 | 
            +
            Paperclip is Copyright © 2008-2017 thoughtbot, inc. It is free software, and may be
         | 
| 988 1036 | 
             
            redistributed under the terms specified in the MIT-LICENSE file.
         | 
| 989 1037 |  | 
| 990 1038 | 
             
            About thoughtbot
         | 
| 991 1039 | 
             
            ----------------
         | 
| 992 1040 |  | 
| 993 | 
            -
            
         | 
| 994 1042 |  | 
| 995 1043 | 
             
            Paperclip is maintained and funded by thoughtbot.
         | 
| 996 1044 | 
             
            The names and logos for thoughtbot are trademarks of thoughtbot, inc.
         | 
    
        data/Rakefile
    CHANGED
    
    | @@ -9,7 +9,7 @@ task :default => [:clean, :all] | |
| 9 9 | 
             
            desc 'Test the paperclip plugin under all supported Rails versions.'
         | 
| 10 10 | 
             
            task :all do |t|
         | 
| 11 11 | 
             
              if ENV['BUNDLE_GEMFILE']
         | 
| 12 | 
            -
                exec('rake spec cucumber')
         | 
| 12 | 
            +
                exec('rake spec && cucumber')
         | 
| 13 13 | 
             
              else
         | 
| 14 14 | 
             
                exec("rm -f gemfiles/*.lock")
         | 
| 15 15 | 
             
                Rake::Task["appraisal:gemfiles"].execute
         | 
    
        data/UPGRADING
    CHANGED
    
    
| @@ -23,7 +23,7 @@ When /^I modify my attachment definition to:$/ do |definition| | |
| 23 23 | 
             
            end
         | 
| 24 24 |  | 
| 25 25 | 
             
            When /^I upload the fixture "([^"]*)"$/ do |filename|
         | 
| 26 | 
            -
              run_simple %(bundle exec  | 
| 26 | 
            +
              run_simple %(bundle exec rails runner "User.create!(:attachment => File.open('#{fixture_path(filename)}'))")
         | 
| 27 27 | 
             
            end
         | 
| 28 28 |  | 
| 29 29 | 
             
            Then /^the attachment "([^"]*)" should have a dimension of (\d+x\d+)$/ do |filename, dimension|
         | 
| @@ -56,7 +56,7 @@ Then /^the attachment should have the same content type as the fixture "([^"]*)" | |
| 56 56 | 
             
                  require "mime/types"
         | 
| 57 57 | 
             
                end
         | 
| 58 58 |  | 
| 59 | 
            -
                attachment_content_type = `bundle exec  | 
| 59 | 
            +
                attachment_content_type = `bundle exec rails runner "puts User.last.attachment_content_type"`.strip
         | 
| 60 60 | 
             
                expected = MIME::Types.type_for(filename).first.content_type
         | 
| 61 61 | 
             
                expect(attachment_content_type).to eq(expected)
         | 
| 62 62 | 
             
              end
         | 
| @@ -64,14 +64,14 @@ end | |
| 64 64 |  | 
| 65 65 | 
             
            Then /^the attachment should have the same file name as the fixture "([^"]*)"$/ do |filename|
         | 
| 66 66 | 
             
              cd(".") do
         | 
| 67 | 
            -
                attachment_file_name = `bundle exec  | 
| 67 | 
            +
                attachment_file_name = `bundle exec rails runner "puts User.last.attachment_file_name"`.strip
         | 
| 68 68 | 
             
                expect(attachment_file_name).to eq(File.name(fixture_path(filename)).to_s)
         | 
| 69 69 | 
             
              end
         | 
| 70 70 | 
             
            end
         | 
| 71 71 |  | 
| 72 72 | 
             
            Then /^the attachment should have the same file size as the fixture "([^"]*)"$/ do |filename|
         | 
| 73 73 | 
             
              cd(".") do
         | 
| 74 | 
            -
                attachment_file_size = `bundle exec  | 
| 74 | 
            +
                attachment_file_size = `bundle exec rails runner "puts User.last.attachment_file_size"`.strip
         | 
| 75 75 | 
             
                expect(attachment_file_size).to eq(File.size(fixture_path(filename)).to_s)
         | 
| 76 76 | 
             
              end
         | 
| 77 77 | 
             
            end
         | 
| @@ -84,7 +84,7 @@ end | |
| 84 84 |  | 
| 85 85 | 
             
            Then /^I should have attachment columns for "([^"]*)"$/ do |attachment_name|
         | 
| 86 86 | 
             
              cd(".") do
         | 
| 87 | 
            -
                columns = eval(`bundle exec  | 
| 87 | 
            +
                columns = eval(`bundle exec rails runner "puts User.columns.map{ |column| [column.name, column.type] }.inspect"`.strip)
         | 
| 88 88 | 
             
                expect_columns = [
         | 
| 89 89 | 
             
                  ["#{attachment_name}_file_name", :string],
         | 
| 90 90 | 
             
                  ["#{attachment_name}_content_type", :string],
         | 
| @@ -97,7 +97,7 @@ end | |
| 97 97 |  | 
| 98 98 | 
             
            Then /^I should not have attachment columns for "([^"]*)"$/ do |attachment_name|
         | 
| 99 99 | 
             
              cd(".") do
         | 
| 100 | 
            -
                columns = eval(`bundle exec  | 
| 100 | 
            +
                columns = eval(`bundle exec rails runner "puts User.columns.map{ |column| [column.name, column.type] }.inspect"`.strip)
         | 
| 101 101 | 
             
                expect_columns = [
         | 
| 102 102 | 
             
                  ["#{attachment_name}_file_name", :string],
         | 
| 103 103 | 
             
                  ["#{attachment_name}_content_type", :string],
         | 
| @@ -1,34 +1,33 @@ | |
| 1 1 | 
             
            Given /^I generate a new rails application$/ do
         | 
| 2 2 | 
             
              steps %{
         | 
| 3 | 
            -
                When I run ` | 
| 3 | 
            +
                When I successfully run `rails new #{APP_NAME} --skip-bundle`
         | 
| 4 4 | 
             
                And I cd to "#{APP_NAME}"
         | 
| 5 | 
            +
              }
         | 
| 6 | 
            +
             | 
| 7 | 
            +
              FileUtils.chdir("tmp/aruba/testapp/")
         | 
| 8 | 
            +
             | 
| 9 | 
            +
              steps %{
         | 
| 5 10 | 
             
                And I turn off class caching
         | 
| 6 | 
            -
                And I fix the application.rb for 3.0.12
         | 
| 7 11 | 
             
                And I write to "Gemfile" with:
         | 
| 8 12 | 
             
                  """
         | 
| 9 13 | 
             
                  source "http://rubygems.org"
         | 
| 10 14 | 
             
                  gem "rails", "#{framework_version}"
         | 
| 11 | 
            -
                  gem "sqlite3",  | 
| 15 | 
            +
                  gem "sqlite3", :platform => [:ruby, :rbx]
         | 
| 12 16 | 
             
                  gem "activerecord-jdbcsqlite3-adapter", :platform => :jruby
         | 
| 13 17 | 
             
                  gem "jruby-openssl", :platform => :jruby
         | 
| 14 18 | 
             
                  gem "capybara"
         | 
| 15 19 | 
             
                  gem "gherkin"
         | 
| 16 | 
            -
                  gem "aws-sdk"
         | 
| 20 | 
            +
                  gem "aws-sdk", "~> 2.0.0"
         | 
| 17 21 | 
             
                  gem "racc", :platform => :rbx
         | 
| 18 22 | 
             
                  gem "rubysl", :platform => :rbx
         | 
| 19 23 | 
             
                  """
         | 
| 20 24 | 
             
                And I remove turbolinks
         | 
| 25 | 
            +
                And I comment out lines that contain "action_mailer" in "config/environments/*.rb"
         | 
| 21 26 | 
             
                And I empty the application.js file
         | 
| 22 27 | 
             
                And I configure the application to use "paperclip" from this project
         | 
| 23 28 | 
             
              }
         | 
| 24 | 
            -
            end
         | 
| 25 29 |  | 
| 26 | 
            -
             | 
| 27 | 
            -
              cd(".") do
         | 
| 28 | 
            -
                File.open("config/application.rb", "a") do |f|
         | 
| 29 | 
            -
                  f << "ActionController::Base.config.relative_url_root = ''"
         | 
| 30 | 
            -
                end
         | 
| 31 | 
            -
              end
         | 
| 30 | 
            +
              FileUtils.chdir("../../..")
         | 
| 32 31 | 
             
            end
         | 
| 33 32 |  | 
| 34 33 | 
             
            Given "I allow the attachment to be submitted" do
         | 
| @@ -51,6 +50,16 @@ Given "I remove turbolinks" do | |
| 51 50 | 
             
              end
         | 
| 52 51 | 
             
            end
         | 
| 53 52 |  | 
| 53 | 
            +
            Given /^I comment out lines that contain "([^"]+)" in "([^"]+)"$/ do |contains, glob|
         | 
| 54 | 
            +
              cd(".") do
         | 
| 55 | 
            +
                Dir.glob(glob).each do |file|
         | 
| 56 | 
            +
                  transform_file(file) do |content|
         | 
| 57 | 
            +
                    content.gsub(/^(.*?#{contains}.*?)$/) { |line| "# #{line}" }
         | 
| 58 | 
            +
                  end
         | 
| 59 | 
            +
                end
         | 
| 60 | 
            +
              end
         | 
| 61 | 
            +
            end
         | 
| 62 | 
            +
             | 
| 54 63 | 
             
            Given /^I attach :attachment$/ do
         | 
| 55 64 | 
             
              attach_attachment("attachment")
         | 
| 56 65 | 
             
            end
         | 
| @@ -60,11 +69,7 @@ Given /^I attach :attachment with:$/ do |definition| | |
| 60 69 | 
             
            end
         | 
| 61 70 |  | 
| 62 71 | 
             
            def attach_attachment(name, definition = nil)
         | 
| 63 | 
            -
              snippet = ""
         | 
| 64 | 
            -
              if using_protected_attributes?
         | 
| 65 | 
            -
                snippet += "attr_accessible :name, :#{name}\n"
         | 
| 66 | 
            -
              end
         | 
| 67 | 
            -
              snippet += "has_attached_file :#{name}"
         | 
| 72 | 
            +
              snippet = "has_attached_file :#{name}"
         | 
| 68 73 | 
             
              if definition
         | 
| 69 74 | 
             
                snippet += ", \n"
         | 
| 70 75 | 
             
                snippet += definition
         | 
| @@ -86,19 +91,19 @@ Given "I empty the application.js file" do | |
| 86 91 | 
             
            end
         | 
| 87 92 |  | 
| 88 93 | 
             
            Given /^I run a rails generator to generate a "([^"]*)" scaffold with "([^"]*)"$/ do |model_name, attributes|
         | 
| 89 | 
            -
              step %[I successfully run ` | 
| 94 | 
            +
              step %[I successfully run `rails generate scaffold #{model_name} #{attributes}`]
         | 
| 90 95 | 
             
            end
         | 
| 91 96 |  | 
| 92 97 | 
             
            Given /^I run a paperclip generator to add a paperclip "([^"]*)" to the "([^"]*)" model$/ do |attachment_name, model_name|
         | 
| 93 | 
            -
              step %[I successfully run ` | 
| 98 | 
            +
              step %[I successfully run `rails generate paperclip #{model_name} #{attachment_name}`]
         | 
| 94 99 | 
             
            end
         | 
| 95 100 |  | 
| 96 101 | 
             
            Given /^I run a migration$/ do
         | 
| 97 | 
            -
              step %[I successfully run ` | 
| 102 | 
            +
              step %[I successfully run `rake db:migrate --trace`]
         | 
| 98 103 | 
             
            end
         | 
| 99 104 |  | 
| 100 105 | 
             
            When /^I rollback a migration$/ do
         | 
| 101 | 
            -
              step %[I successfully run ` | 
| 106 | 
            +
              step %[I successfully run `rake db:rollback STEPS=1 --trace`]
         | 
| 102 107 | 
             
            end
         | 
| 103 108 |  | 
| 104 109 | 
             
            Given /^I update my new user view to include the file upload field$/ do
         | 
| @@ -144,8 +149,10 @@ end | |
| 144 149 |  | 
| 145 150 | 
             
            Given /^I start the rails application$/ do
         | 
| 146 151 | 
             
              cd(".") do
         | 
| 152 | 
            +
                require "rails"
         | 
| 147 153 | 
             
                require "./config/environment"
         | 
| 148 | 
            -
                require "capybara | 
| 154 | 
            +
                require "capybara"
         | 
| 155 | 
            +
                Capybara.app = Rails.application
         | 
| 149 156 | 
             
              end
         | 
| 150 157 | 
             
            end
         | 
| 151 158 |  | 
| @@ -171,7 +178,7 @@ end | |
| 171 178 |  | 
| 172 179 | 
             
            When /^I configure the application to use "([^\"]+)" from this project$/ do |name|
         | 
| 173 180 | 
             
              append_to_gemfile "gem '#{name}', :path => '#{PROJECT_ROOT}'"
         | 
| 174 | 
            -
              steps %{And I run `bundle install --local`}
         | 
| 181 | 
            +
              steps %{And I successfully run `bundle install --local`}
         | 
| 175 182 | 
             
            end
         | 
| 176 183 |  | 
| 177 184 | 
             
            When /^I configure the application to use "([^\"]+)"$/ do |gem_name|
         |