Class: Hydra::Derivatives::Processors::Document

Inherits:
Processor
  • Object
show all
Includes:
ShellBasedProcessor
Defined in:
lib/hydra/derivatives/processors/document.rb

Constant Summary

Constants included from ShellBasedProcessor

ShellBasedProcessor::BLOCK_SIZE

Instance Attribute Summary

Attributes inherited from Processor

#directives, #output_file_service, #source_path

Class Method Summary collapse

Instance Method Summary collapse

Methods included from ShellBasedProcessor

#options_for, #output_file, #process

Methods inherited from Processor

#initialize, #output_file, #output_file_id, #output_filename_for, #process

Constructor Details

This class inherits a constructor from Hydra::Derivatives::Processors::Processor

Class Method Details

.encode(path, format, outdir) ⇒ Object



5
6
7
# File 'lib/hydra/derivatives/processors/document.rb', line 5

def self.encode(path, format, outdir)
  execute "#{Hydra::Derivatives.libreoffice_path} --invisible --headless --convert-to #{format} --outdir #{outdir} #{Shellwords.escape(path)}"
end

Instance Method Details

#encode_file(_file_suffix, _options = {}) ⇒ Object

Converts the document to the format specified in the directives hash. TODO: file_suffix and options are passed from ShellBasedProcessor.process but are not needed.

A refactor could simplify this.


12
13
14
15
16
# File 'lib/hydra/derivatives/processors/document.rb', line 12

def encode_file(_file_suffix, _options = {})
  convert_to_format
ensure
  FileUtils.rm_f(converted_file)
end