Module: Hydra::Derivatives
- Extended by:
- ActiveSupport::Autoload, ActiveSupport::Concern, Deprecation
- Defined in:
- lib/hydra/derivatives.rb,
lib/hydra/derivatives/audio.rb,
lib/hydra/derivatives/image.rb,
lib/hydra/derivatives/video.rb,
lib/hydra/derivatives/config.rb,
lib/hydra/derivatives/ffmpeg.rb,
lib/hydra/derivatives/logger.rb,
lib/hydra/derivatives/document.rb,
lib/hydra/derivatives/processor.rb,
lib/hydra/derivatives/jpeg2k_image.rb,
lib/hydra/derivatives/video/processor.rb,
lib/hydra/derivatives/extract_metadata.rb,
lib/hydra/derivatives/tempfile_service.rb,
lib/hydra/derivatives/shell_based_processor.rb
Defined Under Namespace
Modules: ClassMethods, ExtractMetadata, Ffmpeg, ShellBasedProcessor, Video
Classes: Audio, Config, Document, Image, Jpeg2kImage, Logger, Processor, TempfileService, TimeoutError
Class Method Summary
collapse
Instance Method Summary
collapse
Class Method Details
.config ⇒ Object
27
28
29
|
# File 'lib/hydra/derivatives.rb', line 27
def self.config
@config ||= reset_config!
end
|
.reset_config! ⇒ Object
31
32
33
|
# File 'lib/hydra/derivatives.rb', line 31
def self.reset_config!
@config = Config.new
end
|
Instance Method Details
#constantize_processor(processor) ⇒ Object
99
100
101
102
103
|
# File 'lib/hydra/derivatives.rb', line 99
def constantize_processor(processor)
"Hydra::Derivatives::#{processor.classify}".constantize
rescue NameError
processor.classify.constantize
end
|
#create_derivatives ⇒ Object
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
62
63
64
65
|
# File 'lib/hydra/derivatives.rb', line 53
def create_derivatives
if transformation_schemes.present?
transformation_schemes.each do |transform_scheme|
if transform_scheme.instance_of?(Proc)
transform_scheme.call(self)
else
send(transform_scheme)
end
end
else
logger.warn "`create_derivatives' was called on an instance of #{self.class}, but no derivatives have been requested"
end
end
|
#processor_class(processor) ⇒ Object
90
91
92
93
94
95
96
97
|
# File 'lib/hydra/derivatives.rb', line 90
def processor_class(processor)
case processor
when :video
Hydra::Derivatives::Video::Processor
else
constantize_processor(processor.to_s)
end
end
|
105
106
107
|
# File 'lib/hydra/derivatives.rb', line 105
def transform_datastream(file_name, transform_directives, opts={})
transform_file(file_name, transform_directives, opts={})
end
|
Create derivatives from a file according to transformation directives
85
86
87
88
|
# File 'lib/hydra/derivatives.rb', line 85
def transform_file(file_name, transform_directives, opts={})
processor = processor_class(opts[:processor] || :image)
processor.new(self, file_name, transform_directives).process
end
|