Sha256: bc90d2e4d98c1a942a7c0f5c470afc9a6011b9ee17e03cd932b0ca3fd6d0383a

Contents?: true

Size: 1.74 KB

Versions: 7

Compression:

Stored size: 1.74 KB

Contents

module Hydra
  module Derivatives
    class Runner

      def self.output_file_service= val
        @output_file_service = val
      end

      # Use the output service configured for this class or default to the global setting
      def self.output_file_service
        @output_file_service || Hydra::Derivatives.output_file_service
      end

      def self.source_file_service= val
        @source_file_service = val
      end

      # Use the source service configured for this class or default to the global setting
      def self.source_file_service
        @source_file_service || Hydra::Derivatives.source_file_service
      end


      # @param [String, ActiveFedora::Base] object_or_filename path to the source file, or an object
      # @param [Hash] options options to pass to the encoder
      # @options options [Array] :outputs a list of desired outputs, each entry is a hash that has :label (optional), :format and :url
      def self.create(object_or_filename, options)
        source_file(object_or_filename, options) do |f|
          transform_directives(options.delete(:outputs)).each do |instructions|
            processor_class.new(f.path,
                                instructions.merge(source_file_service: source_file_service),
                                output_file_service: output_file_service).process
          end
        end
      end

      # Override this method if you need to add any defaults
      def self.transform_directives(options)
        options
      end

      def self.source_file(object_or_filename, options, &block)
        source_file_service.call(object_or_filename, options, &block)
      end

      def self.processor_class
        raise "Overide the processor_class method in a sub class"
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

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