Sha256: df32025c698ff10f2fa365c8f03b63d82a19f59fde6855cae1a63eb1a113c66f

Contents?: true

Size: 1.44 KB

Versions: 10

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

10 entries across 10 versions & 1 rubygems

Version Path
hydra-derivatives-3.4.2 lib/hydra/derivatives/processors/processor.rb
hydra-derivatives-3.4.1 lib/hydra/derivatives/processors/processor.rb
hydra-derivatives-3.4.0 lib/hydra/derivatives/processors/processor.rb
hydra-derivatives-3.3.2 lib/hydra/derivatives/processors/processor.rb
hydra-derivatives-3.3.1 lib/hydra/derivatives/processors/processor.rb
hydra-derivatives-3.3.0 lib/hydra/derivatives/processors/processor.rb
hydra-derivatives-3.2.2 lib/hydra/derivatives/processors/processor.rb
hydra-derivatives-3.2.1 lib/hydra/derivatives/processors/processor.rb
hydra-derivatives-3.2.0 lib/hydra/derivatives/processors/processor.rb
hydra-derivatives-3.1.4 lib/hydra/derivatives/processors/processor.rb