Sha256: 3f2aa700ac6381ca4cb95291bec1a366d7f69d7099001148bf4b349e277d0be9

Contents?: true

Size: 1.71 KB

Versions: 14

Compression:

Stored size: 1.71 KB

Contents

module Hydra
  module Derivatives
    class Runner
      class << self
        attr_writer :output_file_service
      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

      class << self
        attr_writer :source_file_service
      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

14 entries across 14 versions & 1 rubygems

Version Path
hydra-derivatives-3.7.0 lib/hydra/derivatives/runners/runner.rb
hydra-derivatives-3.6.1 lib/hydra/derivatives/runners/runner.rb
hydra-derivatives-3.6.0 lib/hydra/derivatives/runners/runner.rb
hydra-derivatives-3.5.0 lib/hydra/derivatives/runners/runner.rb
hydra-derivatives-3.4.2 lib/hydra/derivatives/runners/runner.rb
hydra-derivatives-3.4.1 lib/hydra/derivatives/runners/runner.rb
hydra-derivatives-3.4.0 lib/hydra/derivatives/runners/runner.rb
hydra-derivatives-3.3.2 lib/hydra/derivatives/runners/runner.rb
hydra-derivatives-3.3.1 lib/hydra/derivatives/runners/runner.rb
hydra-derivatives-3.3.0 lib/hydra/derivatives/runners/runner.rb
hydra-derivatives-3.2.2 lib/hydra/derivatives/runners/runner.rb
hydra-derivatives-3.2.1 lib/hydra/derivatives/runners/runner.rb
hydra-derivatives-3.2.0 lib/hydra/derivatives/runners/runner.rb
hydra-derivatives-3.1.4 lib/hydra/derivatives/runners/runner.rb