Sha256: f74f377a312a4dc8a4d899a8a4b948582a0012b4eff901c4837ce562b34f16a4
Contents?: true
Size: 1.26 KB
Versions: 6
Compression:
Stored size: 1.26 KB
Contents
require 'os' require 'libis/tools/extend/string' require 'libis/tools/logger' require 'libis/tools/command' require 'libis/format/config' module Libis module Format module Tool class PdfMerge include ::Libis::Tools::Logger def self.run(source, target, options = []) self.new.run source, target, options end def run(source, target, options = []) source = [source] unless source.is_a?(Array) if OS.java? # TODO: import library and execute in current VM. For now do exactly as in MRI. end timeout = Libis::Format::Config[:timeouts][:pdf_merge] result = Libis::Tools::Command.run( Libis::Format::Config[:java_path], '-cp', Libis::Format::Config[:pdf_tool], 'MergePdf', '--file_output', target, *options, *source, timeout: timeout, kill_after: timeout * 2 ) raise RuntimeError, "#{self.class} took too long (> #{timeout} seconds) to complete" if result[:timeout] raise RuntimeError, "#{self.class} errors: #{result[:err].join("\n")}" unless result[:status] == 0 && result[:err].empty? end end end end end
Version data entries
6 entries across 6 versions & 1 rubygems