Module Paperclip
In: lib/paperclip.rb
lib/paperclip/version.rb
lib/paperclip/storage/filesystem.rb
lib/paperclip/storage/s3.rb
lib/paperclip/thumbnail.rb
lib/paperclip/matchers/validate_attachment_presence_matcher.rb
lib/paperclip/matchers/validate_attachment_size_matcher.rb
lib/paperclip/matchers/have_attached_file_matcher.rb
lib/paperclip/matchers/validate_attachment_content_type_matcher.rb
lib/paperclip/upfile.rb
lib/paperclip/command_line.rb
lib/paperclip/matchers.rb
lib/paperclip/processor.rb
lib/paperclip/style.rb
lib/paperclip/callback_compatability.rb
lib/paperclip/attachment.rb
lib/paperclip/interpolations.rb
lib/paperclip/railtie.rb
lib/paperclip/geometry.rb

encoding: utf-8

Methods

Classes and Modules

Module Paperclip::CallbackCompatability
Module Paperclip::ClassMethods
Module Paperclip::Glue
Module Paperclip::Interpolations
Module Paperclip::Shoulda
Module Paperclip::Storage
Module Paperclip::Upfile
Class Paperclip::Attachment
Class Paperclip::CommandLine
Class Paperclip::CommandNotFoundError
Class Paperclip::Geometry
Class Paperclip::Processor
Class Paperclip::Railtie
Class Paperclip::StorageMethodNotFound
Class Paperclip::Style
Class Paperclip::Tempfile
Class Paperclip::Thumbnail

Constants

VERSION = "2.3.8" unless defined? Paperclip::VERSION

Public Class methods

[Source]

    # File lib/paperclip.rb, line 75
75:     def configure
76:       yield(self) if block_given?
77:     end

[Source]

     # File lib/paperclip.rb, line 116
116:     def each_instance_with_attachment(klass, name)
117:       Object.const_get(klass).all.each do |instance|
118:         yield(instance) if instance.send("#{name}?""#{name}?")
119:       end
120:     end

[Source]

    # File lib/paperclip.rb, line 79
79:     def interpolates key, &block
80:       Paperclip::Interpolations[key] = block
81:     end

Log a paperclip-specific line. Uses ActiveRecord::Base.logger by default. Set Paperclip.options[:log] to false to turn off.

[Source]

     # File lib/paperclip.rb, line 124
124:     def log message
125:       logger.info("[paperclip] #{message}") if logging?
126:     end

Provides configurability to Paperclip. There are a number of options available, such as:

  • whiny: Will raise an error if Paperclip cannot process thumbnails of an uploaded image. Defaults to true.
  • log: Logs progress to the Rails log. Uses ActiveRecord‘s logger, so honors log levels, etc. Defaults to true.
  • command_path: Defines the path at which to find the command line programs if they are not visible to Rails the system‘s search path. Defaults to nil, which uses the first executable found in the user‘s search path.
  • image_magick_path: Deprecated alias of command_path.

[Source]

    # File lib/paperclip.rb, line 64
64:     def options
65:       @options ||= {
66:         :whiny             => true,
67:         :image_magick_path => nil,
68:         :command_path      => nil,
69:         :log               => true,
70:         :log_command       => true,
71:         :swallow_stderr    => true
72:       }
73:     end

The run method takes a command to execute and an array of parameters that get passed to it. The command is prefixed with the :command_path option from Paperclip.options. If you have many commands to run and they are in different paths, the suggested course of action is to symlink them so they are all in the same directory.

If the command returns with a result code that is not one of the expected_outcodes, a PaperclipCommandLineError will be raised. Generally a code of 0 is expected, but a list of codes may be passed if necessary. These codes should be passed as a hash as the last argument, like so:

  Paperclip.run("echo", "something", :expected_outcodes => [0,1,2,3])

This method can log the command being run when Paperclip.options[:log_command] is set to true (defaults to false). This will only log if logging in general is set to true as well.

[Source]

     # File lib/paperclip.rb, line 99
 99:     def run cmd, *params
100:       if options[:image_magick_path]
101:         Paperclip.log("[DEPRECATION] :image_magick_path is deprecated and will be removed. Use :command_path instead")
102:       end
103:       CommandLine.path = options[:command_path] || options[:image_magick_path]
104:       CommandLine.new(cmd, *params).run
105:     end

[Validate]