Class: Hydra::Derivatives::Runner

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

Class Method Summary collapse

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



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

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

.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

.output_file_service=(val) ⇒ Object



5
6
7
# File 'lib/hydra/derivatives/runners/runner.rb', line 5

def self.output_file_service= val
  @output_file_service = val
end

.processor_classObject



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

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

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



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

def self.source_file(object_or_filename, options, &block)
  source_file_service.call(object_or_filename, options, &block)
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

.source_file_service=(val) ⇒ Object



14
15
16
# File 'lib/hydra/derivatives/runners/runner.rb', line 14

def self.source_file_service= val
  @source_file_service = val
end

.transform_directives(options) ⇒ Object

Override this method if you need to add any defaults



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

def self.transform_directives(options)
  options
end