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



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

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



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

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



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

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



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

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

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



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

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



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

def self.transform_directives(options)
  options
end