class BPL::Derivatives::Processors::Processor
Processors
take a single input and produce a single output
Attributes
directives[RW]
object[RW]
output_file_service[RW]
source_path[RW]
Public Class Methods
new(object, directives, opts = {})
click to toggle source
@param [BPL::Derivatives::InputObjectDecorator,BPL::Derivatives::OutputObjectDelegator] @param [Hash] directives directions for creating the output @option [String] :format the format of the output @option [String] :url the location to put the output @param [Hash] opts @option [#call] :output_file_service An output file service to call
# File lib/bpl/derivatives/processors/processor.rb, line 12 def initialize(object, directives, opts = {}) self.object = object self.source_path = object.source_path self.directives = directives self.output_file_service = opts.fetch(:output_file_service, BPL::Derivatives.config.output_file_service) end
Public Instance Methods
finalize_derivative_output(output_io)
click to toggle source
# File lib/bpl/derivatives/processors/processor.rb, line 34 def finalize_derivative_output(output_io) output_object = BPL::Derivatives::OutputObjectDecorator.new(output_io, object) output_file_service.call(output_object, directives) end
output_file()
click to toggle source
@deprecated Please use a PersistOutputFileService
class to save an object
# File lib/bpl/derivatives/processors/processor.rb, line 39 def output_file raise NotImplementedError, "Processor is an abstract class. Utilize an implementation of a PersistOutputFileService class in #{self.class.name}" end
output_file_id(name)
click to toggle source
This governs the output key sent to the persist file service while this is adequate for storing in Fedora, it's not a great name for saving to the file system.
# File lib/bpl/derivatives/processors/processor.rb, line 26 def output_file_id(name) [out_prefix, name].join('_') end
output_filename_for(_name)
click to toggle source
# File lib/bpl/derivatives/processors/processor.rb, line 30 def output_filename_for(_name) File.basename(source_path) end
process()
click to toggle source
# File lib/bpl/derivatives/processors/processor.rb, line 19 def process raise "Processor is an abstract class. Implement `process' on #{self.class.name}" end