Class: Libis::Format::Tool::PdfTool
- Inherits:
-
Object
- Object
- Libis::Format::Tool::PdfTool
- Includes:
- Tools::Logger
- Defined in:
- lib/libis/format/tool/pdf_tool.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_tool.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(command, source, target, *options) ⇒ Object
24 25 26 |
# File 'lib/libis/format/tool/pdf_tool.rb', line 24 def self.run(command, source, target, *) new.run command, source, target, * end |
Instance Method Details
#run(command, 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 |
# File 'lib/libis/format/tool/pdf_tool.rb', line 28 def run(command, 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_tool] args = [ Libis::Format::Config[:java_cmd], '-jar', Libis::Format::Config[:pdf_tool], [command], '-i', source, '-o', target, , ].flatten result = Libis::Tools::Command.run(*args, timeout: , kill_after: timeout * 2) result[:err] << "#{self.class} took too long (> #{timeout} seconds) to complete" if result[:timeout] result end |