Sha256: 541cec8645aba56a14ff51e3c428b07d4e08ceaf1e2f1510301e6c4fc775ad68

Contents?: true

Size: 842 Bytes

Versions: 1

Compression:

Stored size: 842 Bytes

Contents

module Batik
  class Rasterizer
    class RuntimeException < StandardError; end

    attr_reader :options, :command

    def initialize(options = {})
      @options = options
      @command = [
        path_to_java,
        '-Djava.awt.headless=true',
        '-jar',
        path_to_jar_file,
        command_options
      ]
    end

    def rasterize(file)
      command << file
      Open3.popen3(command.join(' ')){|_,_,err| err.read.empty? }
    end

  # private

    def command_options
      options.map {|name, argument| "-#{name} #{argument}"}
    end

    def path_to_java
      options.delete(:java) || "java"
    end

    def path_to_jar_file
      options.delete(:jar_file) ||
        File.join(File.dirname(__FILE__), *%w".. .. vendor batik-1.7 batik-rasterizer.jar")
    end

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
batik-rasterizer-windows-0.1.0 lib/batik/rasterizer.rb