Class: Libis::Format::Tool::PdfCopy
- Inherits:
-
Object
- Object
- Libis::Format::Tool::PdfCopy
- Includes:
- Tools::Logger
- Defined in:
- lib/libis/format/tool/pdf_copy.rb
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.installed? ⇒ Boolean
17 18 19 20 21 22 |
# File 'lib/libis/format/tool/pdf_copy.rb', line 17 def self.installed? result = Libis::Tools::Command.run(Libis::Format::Config[:java_cmd], '-version') return false unless (result[:status]).zero? File.exist?(Libis::Format::Config[:pdf_tool]) end |
.run(source, target, options = []) ⇒ Object
24 25 26 |
# File 'lib/libis/format/tool/pdf_copy.rb', line 24 def self.run(source, target, = []) new.run source, target, end |
Instance Method Details
#run(source, target, options = []) ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/libis/format/tool/pdf_copy.rb', line 28 def run(source, target, = []) 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_copy] result = Libis::Tools::Command.run( Libis::Format::Config[:java_cmd], '-cp', Libis::Format::Config[:pdf_tool], 'CopyPdf', '--file_input', source, '--file_output', target, *, timeout:, kill_after: timeout * 2 ) raise "#{self.class} took too long (> #{timeout} seconds) to complete" if result[:timeout] raise "#{self.class} errors: #{result[:err].join("\n")}" unless (result[:status]).zero? && result[:err].empty? { command: result, files: [target] } end |