Module: Hydra::Derivatives

Extended by:
ActiveSupport::Autoload, ActiveSupport::Concern
Defined in:
lib/hydra/derivatives.rb,
lib/hydra/derivatives/audio.rb,
lib/hydra/derivatives/image.rb,
lib/hydra/derivatives/video.rb,
lib/hydra/derivatives/ffmpeg.rb,
lib/hydra/derivatives/processor.rb,
lib/hydra/derivatives/extract_metadata.rb

Defined Under Namespace

Modules: ClassMethods, ExtractMetadata, Ffmpeg Classes: Audio, Image, Processor, TransformationDirective, Video

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.enable_ffmpegObject



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

def self.enable_ffmpeg
  @enable_ffmpeg ||= true
end

.enable_ffmpeg=(val) ⇒ Object



39
40
41
# File 'lib/hydra/derivatives.rb', line 39

def self.enable_ffmpeg=(val)
  @enable_ffmpeg = val
end

.ffmpeg_pathObject



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

def self.ffmpeg_path
  #Sufia.config.ffmpeg_path
  @ffmpeg_path ||= 'ffmpeg'
end

.ffmpeg_path=(val) ⇒ Object



15
16
17
# File 'lib/hydra/derivatives.rb', line 15

def self.ffmpeg_path=(val)
  @ffmpeg_path = val
end

.fits_pathObject



34
35
36
37
# File 'lib/hydra/derivatives.rb', line 34

def self.fits_path
  #Sufia.config.fits_path
  @fits_path ||= 'fits.sh'
end

.fits_path=(val) ⇒ Object



31
32
33
# File 'lib/hydra/derivatives.rb', line 31

def self.fits_path=(val)
  @fits_path = val
end

.temp_file_baseObject



26
27
28
29
# File 'lib/hydra/derivatives.rb', line 26

def self.temp_file_base
  #Sufia.config.temp_file_base
  @temp_file_base ||= '/tmp'
end

.temp_file_base=(val) ⇒ Object



23
24
25
# File 'lib/hydra/derivatives.rb', line 23

def self.temp_file_base=(val)
  @temp_file_base = val
end

Instance Method Details

#create_derivativesObject

Runs all of the transformations immediately. You may want to run this job in the background as it may take a long time.



53
54
55
56
57
58
59
60
61
# File 'lib/hydra/derivatives.rb', line 53

def create_derivatives 
  if transformation_scheme.present?
    transformation_scheme.each do |datastream, value|
      transform_datastream(datastream, value) if self.datastreams[datastream.to_s].has_content?
    end
  else
    logger.warn "`create_derivatives' was called on an instance of #{self.class}, but no derivatives have been requested"
  end
end

#transform_datastream(datastream, directive_list) ⇒ Object

Transform a single datastream



64
65
66
67
68
69
70
71
72
# File 'lib/hydra/derivatives.rb', line 64

def transform_datastream(datastream, directive_list)
  directive_list.each do |directive|
    if directive.applies?(self)
      processor = directive.processors ? Array(directive.processors).first : :image
      "Hydra::Derivatives::#{processor.to_s.classify}".constantize.new(self, datastream, directive.derivatives).process
    end
  end

end