Sha256: 2a62bfeab5376f96ba45a373bf8cf9b1942f6a5a1c16b24665294949196968b1

Contents?: true

Size: 894 Bytes

Versions: 5

Compression:

Stored size: 894 Bytes

Contents

require_relative "opt_builder"

module MojoMagick
  class Commands
    def self.raw_command(*args)
      execute!(*args)
    end

    class << self
      private

      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

      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
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
mojo_magick-0.6.7 lib/mojo_magick/commands.rb
mojo_magick-0.6.6 lib/mojo_magick/commands.rb
mojo_magick-0.6.5 lib/mojo_magick/commands.rb
mojo_magick-0.6.4 lib/mojo_magick/commands.rb
mojo_magick-0.6.3 lib/mojo_magick/commands.rb