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