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_filename_for, #process

Constructor Details

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

Class Method Details

.encode(path, format, outdir) ⇒ Object



8
9
10
# File 'lib/hydra/derivatives/processors/document.rb', line 8

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.


15
16
17
18
19
# File 'lib/hydra/derivatives/processors/document.rb', line 15

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