Class: Paperclip::CommandLine
- Inherits:
-
Object
- Object
- Paperclip::CommandLine
- Defined in:
- lib/paperclip/command_line.rb
Class Attribute Summary collapse
-
.path ⇒ Object
Returns the value of attribute path.
Instance Method Summary collapse
- #command ⇒ Object
-
#initialize(binary, params = "", options = {}) ⇒ CommandLine
constructor
A new instance of CommandLine.
- #run ⇒ Object
Constructor Details
#initialize(binary, params = "", options = {}) ⇒ CommandLine
Returns a new instance of CommandLine.
7 8 9 10 11 12 13 14 |
# File 'lib/paperclip/command_line.rb', line 7 def initialize(binary, params = "", = {}) @binary = binary.dup @params = params.dup @options = .dup @swallow_stderr = @options.has_key?(:swallow_stderr) ? @options.delete(:swallow_stderr) : Paperclip.[:swallow_stderr] @expected_outcodes = @options.delete(:expected_outcodes) @expected_outcodes ||= [0] end |
Class Attribute Details
.path ⇒ Object
Returns the value of attribute path.
4 5 6 |
# File 'lib/paperclip/command_line.rb', line 4 def path @path end |
Instance Method Details
#command ⇒ Object
16 17 18 19 20 21 22 |
# File 'lib/paperclip/command_line.rb', line 16 def command cmd = [] cmd << full_path(@binary) cmd << interpolate(@params, @options) cmd << bit_bucket if @swallow_stderr cmd.join(" ") end |
#run ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/paperclip/command_line.rb', line 24 def run Paperclip.log(command) begin output = self.class.send(:'`', command) rescue Errno::ENOENT raise Paperclip::CommandNotFoundError end if $?.exitstatus == 127 raise Paperclip::CommandNotFoundError end unless @expected_outcodes.include?($?.exitstatus) raise Paperclip::PaperclipCommandLineError, "Command '#{command}' returned #{$?.exitstatus}. Expected #{@expected_outcodes.join(", ")}" end output end |