korobkov-paperclip 2.3.1.20090921 → 2.3.1.200909221442
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.
- data/README.rdoc +3 -3
- data/Rakefile +2 -1
- data/generators/paperclip/templates/paperclip_migration.rb.erb +2 -2
- data/init.rb +0 -14
- data/lib/paperclip/attachment.rb +11 -11
- data/lib/paperclip/interpolations.rb +5 -1
- data/lib/paperclip/upfile.rb +4 -4
- data/tasks/paperclip_tasks.rake +2 -2
- metadata +41 -31
    
        data/README.rdoc
    CHANGED
    
    | @@ -30,7 +30,7 @@ In your migrations: | |
| 30 30 | 
             
                  add_column :users, :avatar_file_name,    :string
         | 
| 31 31 | 
             
                  add_column :users, :avatar_content_type, :string
         | 
| 32 32 | 
             
                  add_column :users, :avatar_file_size,    :integer
         | 
| 33 | 
            -
                  add_column :users, : | 
| 33 | 
            +
                  add_column :users, :avatar_file_hexdigest, :string
         | 
| 34 34 | 
             
                  add_column :users, :avatar_updated_at,   :datetime
         | 
| 35 35 | 
             
                end
         | 
| 36 36 |  | 
| @@ -38,7 +38,7 @@ In your migrations: | |
| 38 38 | 
             
                  remove_column :users, :avatar_file_name
         | 
| 39 39 | 
             
                  remove_column :users, :avatar_content_type
         | 
| 40 40 | 
             
                  remove_column :users, :avatar_file_size
         | 
| 41 | 
            -
                  remove_column :users, : | 
| 41 | 
            +
                  remove_column :users, :avatar_file_hexdigest
         | 
| 42 42 | 
             
                  remove_column :users, :avatar_updated_at
         | 
| 43 43 | 
             
                end
         | 
| 44 44 | 
             
              end
         | 
| @@ -68,7 +68,7 @@ attachment with the has_attached_file method, and give it a name. Paperclip | |
| 68 68 | 
             
            will wrap up up to four attributes (all prefixed with that attachment's name,
         | 
| 69 69 | 
             
            so you can have multiple attachments per model if you wish) and give the a
         | 
| 70 70 | 
             
            friendly front end. The attributes are <attachment>_file_name,
         | 
| 71 | 
            -
            <attachment>_file_size, <attachment> | 
| 71 | 
            +
            <attachment>_file_size, <attachment>_file_hexdigest, <attachment>_content_type,
         | 
| 72 72 | 
             
            and <attachment>_updated_at.
         | 
| 73 73 | 
             
            Only <attachment>_file_name is required for paperclip to operate. More
         | 
| 74 74 | 
             
            information about the options to has_attached_file is available in the
         | 
    
        data/Rakefile
    CHANGED
    
    | @@ -61,7 +61,7 @@ exclude_file_globs = ["test/s3.yml", | |
| 61 61 | 
             
                                  "test/tmp/*"]
         | 
| 62 62 | 
             
            spec = Gem::Specification.new do |s| 
         | 
| 63 63 | 
             
              s.name              = "paperclip"
         | 
| 64 | 
            -
              s.version           = Paperclip::VERSION
         | 
| 64 | 
            +
              s.version           = Paperclip::VERSION + "." + Time.now.strftime("%Y%m%d%H%M")
         | 
| 65 65 | 
             
              s.author            = "Jon Yurek"
         | 
| 66 66 | 
             
              s.email             = "jyurek@thoughtbot.com"
         | 
| 67 67 | 
             
              s.homepage          = "http://www.thoughtbot.com/projects/paperclip"
         | 
| @@ -77,6 +77,7 @@ spec = Gem::Specification.new do |s| | |
| 77 77 | 
             
              s.requirements << "ImageMagick"
         | 
| 78 78 | 
             
              s.add_development_dependency 'thoughtbot-shoulda'
         | 
| 79 79 | 
             
              s.add_development_dependency 'mocha'
         | 
| 80 | 
            +
              s.add_dependency 'minad-mimemagic'
         | 
| 80 81 | 
             
            end
         | 
| 81 82 |  | 
| 82 83 | 
             
            desc "Print a list of the files to be put into the gem"
         | 
| @@ -4,7 +4,7 @@ class <%= migration_name %> < ActiveRecord::Migration | |
| 4 4 | 
             
                add_column :<%= class_name.underscore.camelize.tableize %>, :<%= attachment %>_file_name, :string
         | 
| 5 5 | 
             
                add_column :<%= class_name.underscore.camelize.tableize %>, :<%= attachment %>_content_type, :string
         | 
| 6 6 | 
             
                add_column :<%= class_name.underscore.camelize.tableize %>, :<%= attachment %>_file_size, :integer
         | 
| 7 | 
            -
                add_column :<%= class_name.underscore.camelize.tableize %>, :<%= attachment %> | 
| 7 | 
            +
                add_column :<%= class_name.underscore.camelize.tableize %>, :<%= attachment %>_file_hexdigest, :string
         | 
| 8 8 | 
             
                add_column :<%= class_name.underscore.camelize.tableize %>, :<%= attachment %>_updated_at, :datetime
         | 
| 9 9 | 
             
            <% end -%>
         | 
| 10 10 | 
             
              end
         | 
| @@ -14,7 +14,7 @@ class <%= migration_name %> < ActiveRecord::Migration | |
| 14 14 | 
             
                remove_column :<%= class_name.underscore.camelize.tableize %>, :<%= attachment %>_file_name
         | 
| 15 15 | 
             
                remove_column :<%= class_name.underscore.camelize.tableize %>, :<%= attachment %>_content_type
         | 
| 16 16 | 
             
                remove_column :<%= class_name.underscore.camelize.tableize %>, :<%= attachment %>_file_size
         | 
| 17 | 
            -
                remove_column :<%= class_name.underscore.camelize.tableize %>, :<%= attachment %> | 
| 17 | 
            +
                remove_column :<%= class_name.underscore.camelize.tableize %>, :<%= attachment %>_file_hexdigest
         | 
| 18 18 | 
             
                remove_column :<%= class_name.underscore.camelize.tableize %>, :<%= attachment %>_updated_at
         | 
| 19 19 | 
             
            <% end -%>
         | 
| 20 20 | 
             
              end
         | 
    
        data/init.rb
    CHANGED
    
    | @@ -1,15 +1 @@ | |
| 1 | 
            -
            if config.respond_to?(:gems)
         | 
| 2 | 
            -
              config.gem 'minad-mimemagic', :lib => 'mimemagic'
         | 
| 3 | 
            -
            else
         | 
| 4 | 
            -
              begin
         | 
| 5 | 
            -
                require 'mimemagic'
         | 
| 6 | 
            -
              rescue LoadError
         | 
| 7 | 
            -
                begin
         | 
| 8 | 
            -
                  gem 'mimemagic'
         | 
| 9 | 
            -
                rescue Gem::LoadError
         | 
| 10 | 
            -
                  puts "Please install the mimemagic gem"
         | 
| 11 | 
            -
                end
         | 
| 12 | 
            -
              end
         | 
| 13 | 
            -
            end
         | 
| 14 | 
            -
             | 
| 15 1 | 
             
            require File.join(File.dirname(__FILE__), "lib", "paperclip")
         | 
    
        data/lib/paperclip/attachment.rb
    CHANGED
    
    | @@ -15,7 +15,7 @@ module Paperclip | |
| 15 15 | 
             
                    :validations   => [],
         | 
| 16 16 | 
             
                    :storage       => :filesystem,
         | 
| 17 17 | 
             
                    :whiny         => Paperclip.options[:whiny] || Paperclip.options[:whiny_thumbnails],
         | 
| 18 | 
            -
                    : | 
| 18 | 
            +
                    :digest_bitlength   => 512
         | 
| 19 19 | 
             
                  }
         | 
| 20 20 | 
             
                end
         | 
| 21 21 |  | 
| @@ -41,7 +41,7 @@ module Paperclip | |
| 41 41 | 
             
                  @validations       = options[:validations]
         | 
| 42 42 | 
             
                  @storage           = options[:storage]
         | 
| 43 43 | 
             
                  @whiny             = options[:whiny_thumbnails] || options[:whiny]
         | 
| 44 | 
            -
                  @ | 
| 44 | 
            +
                  @digest_bitlength  = options[:digest_bitlength]
         | 
| 45 45 | 
             
                  @convert_options   = options[:convert_options] || {}
         | 
| 46 46 | 
             
                  @processors        = options[:processors] || [:thumbnail]
         | 
| 47 47 | 
             
                  @options           = options
         | 
| @@ -80,18 +80,18 @@ module Paperclip | |
| 80 80 |  | 
| 81 81 | 
             
                  @queued_for_write[:original]   = uploaded_file.to_tempfile
         | 
| 82 82 | 
             
                  instance_write(:file_name,       uploaded_file.original_filename.strip.gsub(/[^A-Za-z\d\.\-_]+/, '_'))
         | 
| 83 | 
            -
                  instance_write(:content_type,    uploaded_file.content_type. | 
| 83 | 
            +
                  instance_write(:content_type,    uploaded_file.content_type.strip)
         | 
| 84 84 | 
             
                  instance_write(:file_size,       uploaded_file.size.to_i)
         | 
| 85 | 
            -
                  instance_write(: | 
| 85 | 
            +
                  instance_write(:file_hexdigest,  uploaded_file.hexdigest)
         | 
| 86 86 | 
             
                  instance_write(:updated_at,      Time.now)
         | 
| 87 87 |  | 
| 88 88 | 
             
                  @dirty = true
         | 
| 89 89 |  | 
| 90 90 | 
             
                  post_process if valid?
         | 
| 91 91 |  | 
| 92 | 
            -
                  # Reset the file size and  | 
| 92 | 
            +
                  # Reset the file size and hexdigest if the original file was reprocessed.
         | 
| 93 93 | 
             
                  instance_write(:file_size, @queued_for_write[:original].size.to_i)
         | 
| 94 | 
            -
                  instance_write(: | 
| 94 | 
            +
                  instance_write(:file_hexdigest, @queued_for_write[:original].hexdigest)
         | 
| 95 95 | 
             
                ensure
         | 
| 96 96 | 
             
                  uploaded_file.close if close_uploaded_file
         | 
| 97 97 | 
             
                  validate
         | 
| @@ -181,10 +181,10 @@ module Paperclip | |
| 181 181 | 
             
                  instance_read(:file_size) || (@queued_for_write[:original] && @queued_for_write[:original].size)
         | 
| 182 182 | 
             
                end
         | 
| 183 183 |  | 
| 184 | 
            -
                # Returns the  | 
| 185 | 
            -
                # <attachment> | 
| 186 | 
            -
                def  | 
| 187 | 
            -
                  instance_read(: | 
| 184 | 
            +
                # Returns the hexdigest of the file as originally assigned, and lives in the
         | 
| 185 | 
            +
                # <attachment>_file_hexdigest attribute of the model.
         | 
| 186 | 
            +
                def hexdigest
         | 
| 187 | 
            +
                  instance_read(:file_hexdigest) || (@queued_for_write[:original] && @queued_for_write[:original].hexdigest)
         | 
| 188 188 | 
             
                end
         | 
| 189 189 |  | 
| 190 190 | 
             
                # Returns the content_type of the file as originally assigned, and lives
         | 
| @@ -410,7 +410,7 @@ module Paperclip | |
| 410 410 | 
             
                  instance_write(:file_name, nil)
         | 
| 411 411 | 
             
                  instance_write(:content_type, nil)
         | 
| 412 412 | 
             
                  instance_write(:file_size, nil)
         | 
| 413 | 
            -
                  instance_write(: | 
| 413 | 
            +
                  instance_write(:file_hexdigest, nil)
         | 
| 414 414 | 
             
                  instance_write(:updated_at, nil)
         | 
| 415 415 | 
             
                end
         | 
| 416 416 |  | 
| @@ -35,7 +35,11 @@ module Paperclip | |
| 35 35 |  | 
| 36 36 | 
             
                # Returns the filename, the same way as ":basename.:extension" would.
         | 
| 37 37 | 
             
                def filename attachment, style
         | 
| 38 | 
            -
                   | 
| 38 | 
            +
                  unless extension(attachment, style).strip.empty?
         | 
| 39 | 
            +
                  	"#{basename(attachment, style)}.#{extension(attachment, style)}"
         | 
| 40 | 
            +
                  else
         | 
| 41 | 
            +
                  	basename(attachment, style)
         | 
| 42 | 
            +
                  end
         | 
| 39 43 | 
             
                end
         | 
| 40 44 |  | 
| 41 45 | 
             
                # Returns the interpolated URL. Will raise an error if the url itself
         | 
    
        data/lib/paperclip/upfile.rb
    CHANGED
    
    | @@ -9,7 +9,7 @@ module Paperclip | |
| 9 9 |  | 
| 10 10 | 
             
                # Infer the MIME-type of the file from the magic.
         | 
| 11 11 | 
             
                def content_type
         | 
| 12 | 
            -
                   MimeMagic.by_magic( | 
| 12 | 
            +
                   MimeMagic.by_magic(self).type
         | 
| 13 13 | 
             
                end
         | 
| 14 14 |  | 
| 15 15 | 
             
                # Returns the file's normal name.
         | 
| @@ -22,9 +22,9 @@ module Paperclip | |
| 22 22 | 
             
                  File.size(self)
         | 
| 23 23 | 
             
                end
         | 
| 24 24 |  | 
| 25 | 
            -
                # Returns the  | 
| 26 | 
            -
                def  | 
| 27 | 
            -
                  Digest::SHA2.new(512). | 
| 25 | 
            +
                # Returns the hexdigest of the file.
         | 
| 26 | 
            +
                def hexdigest
         | 
| 27 | 
            +
                  Digest::SHA2.new(512).hexdigest(self.read) # FIXME needed actual digest_bitlength from Attachment class instead of "512" constant
         | 
| 28 28 | 
             
                end
         | 
| 29 29 | 
             
              end
         | 
| 30 30 | 
             
            end
         | 
    
        data/tasks/paperclip_tasks.rake
    CHANGED
    
    | @@ -49,14 +49,14 @@ namespace :paperclip do | |
| 49 49 | 
             
                  errors.each{|e| puts "#{e.first}: #{e.last.full_messages.inspect}" }
         | 
| 50 50 | 
             
                end
         | 
| 51 51 |  | 
| 52 | 
            -
                desc "Regenerates content_type/size/ | 
| 52 | 
            +
                desc "Regenerates content_type/size/hexdigest metadata for a given CLASS (and optional ATTACHMENT)."
         | 
| 53 53 | 
             
                task :metadata => :environment do
         | 
| 54 54 | 
             
                  for_all_attachments do |instance, name|
         | 
| 55 55 | 
             
                    if file = instance.send(name).to_file
         | 
| 56 56 | 
             
                      instance.send("#{name}_file_name=", instance.send("#{name}_file_name").strip)
         | 
| 57 57 | 
             
                      instance.send("#{name}_content_type=", file.content_type.strip)
         | 
| 58 58 | 
             
                      instance.send("#{name}_file_size=", file.size) if instance.respond_to?("#{name}_file_size")
         | 
| 59 | 
            -
                      instance.send("#{name} | 
| 59 | 
            +
                      instance.send("#{name}_file_hexdigest=", file.hexdigest) if instance.respond_to?("#{name}_file_hexdigest")
         | 
| 60 60 | 
             
                      instance.save(false)
         | 
| 61 61 | 
             
                    else
         | 
| 62 62 | 
             
                      true
         | 
    
        metadata
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification 
         | 
| 2 2 | 
             
            name: korobkov-paperclip
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version 
         | 
| 4 | 
            -
              version: 2.3.1. | 
| 4 | 
            +
              version: 2.3.1.200909221442
         | 
| 5 5 | 
             
            platform: ruby
         | 
| 6 6 | 
             
            authors: 
         | 
| 7 7 | 
             
            - Jon Yurek
         | 
| @@ -9,7 +9,7 @@ autorequire: | |
| 9 9 | 
             
            bindir: bin
         | 
| 10 10 | 
             
            cert_chain: []
         | 
| 11 11 |  | 
| 12 | 
            -
            date: 2009- | 
| 12 | 
            +
            date: 2009-09-22 00:00:00 -07:00
         | 
| 13 13 | 
             
            default_executable: 
         | 
| 14 14 | 
             
            dependencies: 
         | 
| 15 15 | 
             
            - !ruby/object:Gem::Dependency 
         | 
| @@ -32,6 +32,16 @@ dependencies: | |
| 32 32 | 
             
                  - !ruby/object:Gem::Version 
         | 
| 33 33 | 
             
                    version: "0"
         | 
| 34 34 | 
             
                version: 
         | 
| 35 | 
            +
            - !ruby/object:Gem::Dependency 
         | 
| 36 | 
            +
              name: minad-mimemagic
         | 
| 37 | 
            +
              type: :runtime
         | 
| 38 | 
            +
              version_requirement: 
         | 
| 39 | 
            +
              version_requirements: !ruby/object:Gem::Requirement 
         | 
| 40 | 
            +
                requirements: 
         | 
| 41 | 
            +
                - - ">="
         | 
| 42 | 
            +
                  - !ruby/object:Gem::Version 
         | 
| 43 | 
            +
                    version: "0"
         | 
| 44 | 
            +
                version: 
         | 
| 35 45 | 
             
            description: 
         | 
| 36 46 | 
             
            email: jyurek@thoughtbot.com
         | 
| 37 47 | 
             
            executables: []
         | 
| @@ -46,54 +56,54 @@ files: | |
| 46 56 | 
             
            - Rakefile
         | 
| 47 57 | 
             
            - init.rb
         | 
| 48 58 | 
             
            - generators/paperclip
         | 
| 59 | 
            +
            - generators/paperclip/USAGE
         | 
| 49 60 | 
             
            - generators/paperclip/paperclip_generator.rb
         | 
| 50 61 | 
             
            - generators/paperclip/templates
         | 
| 51 62 | 
             
            - generators/paperclip/templates/paperclip_migration.rb.erb
         | 
| 52 | 
            -
            - generators/paperclip/USAGE
         | 
| 53 63 | 
             
            - lib/paperclip
         | 
| 54 | 
            -
            - lib/paperclip/ | 
| 55 | 
            -
            - lib/paperclip/ | 
| 56 | 
            -
            - lib/paperclip/ | 
| 64 | 
            +
            - lib/paperclip/matchers.rb
         | 
| 65 | 
            +
            - lib/paperclip/upfile.rb
         | 
| 66 | 
            +
            - lib/paperclip/processor.rb
         | 
| 57 67 | 
             
            - lib/paperclip/interpolations.rb
         | 
| 58 | 
            -
            - lib/paperclip/ | 
| 68 | 
            +
            - lib/paperclip/geometry.rb
         | 
| 59 69 | 
             
            - lib/paperclip/matchers
         | 
| 60 | 
            -
            - lib/paperclip/matchers/have_attached_file_matcher.rb
         | 
| 61 | 
            -
            - lib/paperclip/matchers/validate_attachment_content_type_matcher.rb
         | 
| 62 | 
            -
            - lib/paperclip/matchers/validate_attachment_presence_matcher.rb
         | 
| 63 70 | 
             
            - lib/paperclip/matchers/validate_attachment_size_matcher.rb
         | 
| 64 | 
            -
            - lib/paperclip/matchers.rb
         | 
| 65 | 
            -
            - lib/paperclip/ | 
| 71 | 
            +
            - lib/paperclip/matchers/validate_attachment_presence_matcher.rb
         | 
| 72 | 
            +
            - lib/paperclip/matchers/validate_attachment_content_type_matcher.rb
         | 
| 73 | 
            +
            - lib/paperclip/matchers/have_attached_file_matcher.rb
         | 
| 66 74 | 
             
            - lib/paperclip/storage.rb
         | 
| 75 | 
            +
            - lib/paperclip/iostream.rb
         | 
| 76 | 
            +
            - lib/paperclip/callback_compatability.rb
         | 
| 77 | 
            +
            - lib/paperclip/attachment.rb
         | 
| 67 78 | 
             
            - lib/paperclip/thumbnail.rb
         | 
| 68 | 
            -
            - lib/paperclip/upfile.rb
         | 
| 69 79 | 
             
            - lib/paperclip.rb
         | 
| 70 80 | 
             
            - tasks/paperclip_tasks.rake
         | 
| 71 | 
            -
            - test/ | 
| 72 | 
            -
            - test/database.yml
         | 
| 73 | 
            -
            - test/fixtures
         | 
| 74 | 
            -
            - test/fixtures/12k.png
         | 
| 75 | 
            -
            - test/fixtures/50x50.png
         | 
| 76 | 
            -
            - test/fixtures/5k.png
         | 
| 77 | 
            -
            - test/fixtures/bad.png
         | 
| 78 | 
            -
            - test/fixtures/s3.yml
         | 
| 79 | 
            -
            - test/fixtures/text.txt
         | 
| 80 | 
            -
            - test/fixtures/twopage.pdf
         | 
| 81 | 
            -
            - test/geometry_test.rb
         | 
| 82 | 
            -
            - test/helper.rb
         | 
| 83 | 
            -
            - test/integration_test.rb
         | 
| 84 | 
            -
            - test/interpolations_test.rb
         | 
| 81 | 
            +
            - test/processor_test.rb
         | 
| 85 82 | 
             
            - test/iostream_test.rb
         | 
| 86 83 | 
             
            - test/matchers
         | 
| 87 84 | 
             
            - test/matchers/have_attached_file_matcher_test.rb
         | 
| 88 | 
            -
            - test/matchers/validate_attachment_content_type_matcher_test.rb
         | 
| 89 85 | 
             
            - test/matchers/validate_attachment_presence_matcher_test.rb
         | 
| 90 86 | 
             
            - test/matchers/validate_attachment_size_matcher_test.rb
         | 
| 87 | 
            +
            - test/matchers/validate_attachment_content_type_matcher_test.rb
         | 
| 88 | 
            +
            - test/interpolations_test.rb
         | 
| 89 | 
            +
            - test/fixtures
         | 
| 90 | 
            +
            - test/fixtures/text.txt
         | 
| 91 | 
            +
            - test/fixtures/twopage.pdf
         | 
| 92 | 
            +
            - test/fixtures/s3.yml
         | 
| 93 | 
            +
            - test/fixtures/50x50.png
         | 
| 94 | 
            +
            - test/fixtures/bad.png
         | 
| 95 | 
            +
            - test/fixtures/5k.png
         | 
| 96 | 
            +
            - test/fixtures/12k.png
         | 
| 97 | 
            +
            - test/attachment_test.rb
         | 
| 91 98 | 
             
            - test/paperclip_test.rb
         | 
| 92 | 
            -
            - test/ | 
| 99 | 
            +
            - test/database.yml
         | 
| 93 100 | 
             
            - test/storage_test.rb
         | 
| 94 101 | 
             
            - test/thumbnail_test.rb
         | 
| 102 | 
            +
            - test/integration_test.rb
         | 
| 103 | 
            +
            - test/helper.rb
         | 
| 104 | 
            +
            - test/geometry_test.rb
         | 
| 95 105 | 
             
            - shoulda_macros/paperclip.rb
         | 
| 96 | 
            -
            has_rdoc:  | 
| 106 | 
            +
            has_rdoc: false
         | 
| 97 107 | 
             
            homepage: http://www.thoughtbot.com/projects/paperclip
         | 
| 98 108 | 
             
            licenses: 
         | 
| 99 109 | 
             
            post_install_message: 
         | 
| @@ -119,7 +129,7 @@ requirements: | |
| 119 129 | 
             
            rubyforge_project: paperclip
         | 
| 120 130 | 
             
            rubygems_version: 1.3.5
         | 
| 121 131 | 
             
            signing_key: 
         | 
| 122 | 
            -
            specification_version:  | 
| 132 | 
            +
            specification_version: 3
         | 
| 123 133 | 
             
            summary: File attachments as attributes for ActiveRecord
         | 
| 124 134 | 
             
            test_files: []
         | 
| 125 135 |  |