Module Paperclip
In: lib/paperclip/attachment.rb
lib/paperclip/callback_compatability.rb
lib/paperclip/geometry.rb
lib/paperclip/interpolations.rb
lib/paperclip/matchers/have_attached_file_matcher.rb
lib/paperclip/matchers/validate_attachment_content_type_matcher.rb
lib/paperclip/matchers/validate_attachment_presence_matcher.rb
lib/paperclip/matchers/validate_attachment_size_matcher.rb
lib/paperclip/processor.rb
lib/paperclip/storage.rb
lib/paperclip/thumbnail.rb
lib/paperclip/upfile.rb
lib/paperclip.rb

The base module that gets included in ActiveRecord::Base. See the documentation for Paperclip::ClassMethods for more useful information.

Methods

interpolates   log   options   run  

Classes and Modules

Module Paperclip::CallbackCompatability
Module Paperclip::ClassMethods
Module Paperclip::Interpolations
Module Paperclip::Shoulda
Module Paperclip::Storage
Module Paperclip::Upfile
Class Paperclip::Attachment
Class Paperclip::Geometry
Class Paperclip::Processor
Class Paperclip::Tempfile
Class Paperclip::Thumbnail

Constants

VERSION = "2.2.9"

Public Class methods

[Source]

    # File lib/paperclip.rb, line 78
78:     def interpolates key, &block
79:       Paperclip::Interpolations[key] = block
80:     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 128
128:     def log message
129:       logger.info("[paperclip] #{message}") if logging?
130:     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 59
59:     def options
60:       @options ||= {
61:         :whiny             => true,
62:         :image_magick_path => nil,
63:         :command_path      => nil,
64:         :log               => true,
65:         :log_command       => false,
66:         :swallow_stderr    => true
67:       }
68:     end

The run method takes a command to execute and a string 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.

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 95
 95:     def run cmd, params = "", expected_outcodes = 0
 96:       command = %Q<#{%Q[#{path_for_command(cmd)} #{params}].gsub(/\s+/, " ")}>
 97:       command = "#{command} 2>#{bit_bucket}" if Paperclip.options[:swallow_stderr]
 98:       Paperclip.log(command) if Paperclip.options[:log_command]
 99:       output = `#{command}`
100:       unless [expected_outcodes].flatten.include?($?.exitstatus)
101:         raise PaperclipCommandLineError, "Error while running #{cmd}"
102:       end
103:       output
104:     end

[Validate]