The base module that gets included in ActiveRecord::Base. See the documentation for Paperclip::ClassMethods for more useful information.
| VERSION | = | "2.2.9" |
# 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.
# 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:
# 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.
# 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