Class Paperclip::CommandLine
In: lib/paperclip/command_line.rb
Parent: Object

Methods

command   new   run  

Attributes

path  [RW] 

Public Class methods

[Source]

    # File lib/paperclip/command_line.rb, line 7
 7:     def initialize(binary, params = "", options = {})
 8:       @binary            = binary.dup
 9:       @params            = params.dup
10:       @options           = options.dup
11:       @swallow_stderr    = @options.has_key?(:swallow_stderr) ? @options.delete(:swallow_stderr) : Paperclip.options[:swallow_stderr]
12:       @expected_outcodes = @options.delete(:expected_outcodes)
13:       @expected_outcodes ||= [0]
14:     end

Public Instance methods

[Source]

    # File lib/paperclip/command_line.rb, line 16
16:     def command
17:       cmd = []
18:       cmd << full_path(@binary)
19:       cmd << interpolate(@params, @options)
20:       cmd << bit_bucket if @swallow_stderr
21:       cmd.join(" ")
22:     end

[Source]

    # File lib/paperclip/command_line.rb, line 24
24:     def run
25:       Paperclip.log(command)
26:       begin
27:         output = self.class.send('`''`', command)
28:       rescue Errno::ENOENT
29:         raise Paperclip::CommandNotFoundError
30:       end
31:       if $?.exitstatus == 127
32:         raise Paperclip::CommandNotFoundError
33:       end
34:       unless @expected_outcodes.include?($?.exitstatus)
35:         raise Paperclip::PaperclipCommandLineError, "Command '#{command}' returned #{$?.exitstatus}. Expected #{@expected_outcodes.join(", ")}"
36:       end
37:       output
38:     end

[Validate]