Class: Hydra::Derivatives::Runner

Inherits:
Object
  • Object
show all
Defined in:
lib/hydra/derivatives/runners/runner.rb

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.output_file_serviceObject

Use the output service configured for this class or default to the global setting


9
10
11
# File 'lib/hydra/derivatives/runners/runner.rb', line 9

def self.output_file_service
  @output_file_service || Hydra::Derivatives.output_file_service
end

.source_file_serviceObject

Use the source service configured for this class or default to the global setting


18
19
20
# File 'lib/hydra/derivatives/runners/runner.rb', line 18

def self.source_file_service
  @source_file_service || Hydra::Derivatives.source_file_service
end

Class Method Details

.create(object_or_filename, options) ⇒ Object

Parameters:

  • object_or_filename (String, ActiveFedora::Base)

    path to the source file, or an object

  • options (Hash)

    options to pass to the encoder


25
26
27
28
29
30
31
32
33
# File 'lib/hydra/derivatives/runners/runner.rb', line 25

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

.processor_classObject


44
45
46
# File 'lib/hydra/derivatives/runners/runner.rb', line 44

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

.source_file(object_or_filename, options, &block) ⇒ Object


40
41
42
# File 'lib/hydra/derivatives/runners/runner.rb', line 40

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

.transform_directives(options) ⇒ Object

Override this method if you need to add any defaults


36
37
38
# File 'lib/hydra/derivatives/runners/runner.rb', line 36

def self.transform_directives(options)
  options
end