Sha256: 2df51dc422b0cc218303e750bac5d8225579e3531566a0fb6f71598be82b6387

Contents?: true

Size: 1.44 KB

Versions: 7

Compression:

Stored size: 1.44 KB

Contents

module Hydra::Derivatives::Processors
  # Processors take a single input and produce a single output
  class Processor
    attr_accessor :source_path, :directives, :output_file_service

    # @param [String] source_path path to the file on disk
    # @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
    def initialize(source_path, directives, opts={})
      self.source_path = source_path
      self.directives = directives
      self.output_file_service = opts.fetch(:output_file_service, Hydra::Derivatives.output_file_service)
    end

    def process
      raise "Processor is an abstract class. Implement `process' on #{self.class.name}"
    end

    # 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.
    def output_file_id(name)
      [out_prefix, name].join('_')
    end

    def output_filename_for(_name)
      File.basename(source_path)
    end

    # @deprecated Please use a PersistOutputFileService class to save an object
    def output_file
      raise NotImplementedError, "Processor is an abstract class. Utilize an implementation of a PersistOutputFileService class in #{self.class.name}"
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
hydra-derivatives-3.1.3 lib/hydra/derivatives/processors/processor.rb
hydra-derivatives-3.1.2 lib/hydra/derivatives/processors/processor.rb
hydra-derivatives-3.1.1 lib/hydra/derivatives/processors/processor.rb
hydra-derivatives-3.1.0 lib/hydra/derivatives/processors/processor.rb
hydra-derivatives-3.0.2 lib/hydra/derivatives/processors/processor.rb
hydra-derivatives-3.0.1 lib/hydra/derivatives/processors/processor.rb
hydra-derivatives-3.0.0 lib/hydra/derivatives/processors/processor.rb