class MojoMagick::Commands

Public Class Methods

raw_command(*args) click to toggle source
# File lib/mojo_magick/commands.rb, line 5
def self.raw_command(*args)
  execute!(*args)
end

Private Class Methods

execute(command, *args) click to toggle source
# File lib/mojo_magick/commands.rb, line 12
def execute(command, *args)
  execute = "#{command} #{args}"
  out, outerr, status = Open3.capture3(command, *args.map(&:to_s))
  CommandStatus.new execute, out, outerr, status
rescue StandardError => e
  raise MojoError, "#{e.class}: #{e.message}"
end
execute!(command, *args) click to toggle source
# File lib/mojo_magick/commands.rb, line 20
def execute!(command, *args)
  status = execute(command, *args)
  unless status.success?
    err_msg = "MojoMagick command failed: #{command}."
    raise(MojoFailed, "#{err_msg} (Exit status: #{status.exit_code})\n  " \
                      "Command: #{status.command}\n  " \
                      "Error: #{status.error}")
  end
  status.return_value
end