Module: BPL::Derivatives::Processors::ShellBasedProcessor
- Extended by:
- ActiveSupport::Concern
- Included in:
- Document, Jpeg2kImage
- Defined in:
- lib/bpl/derivatives/processors/shell_based_processor.rb
Defined Under Namespace
Modules: ClassMethods
Constant Summary collapse
- BLOCK_SIZE =
1024
Instance Method Summary collapse
- #encode_file(file_suffix, options) ⇒ Object
-
#options_for(_format) ⇒ Object
override this method in subclass if you want to provide specific options.
- #output_file(file_suffix) ⇒ Object
- #process ⇒ Object
Instance Method Details
#encode_file(file_suffix, options) ⇒ Object
30 31 32 33 34 35 |
# File 'lib/bpl/derivatives/processors/shell_based_processor.rb', line 30 def encode_file(file_suffix, ) temp_file_name = output_file(file_suffix) self.class.encode(source_path, , temp_file_name) finalize_derivative_output(File.read(temp_file_name)) File.unlink(temp_file_name) end |
#options_for(_format) ⇒ Object
override this method in subclass if you want to provide specific options. returns a hash of options that the specific processors use
26 27 28 |
# File 'lib/bpl/derivatives/processors/shell_based_processor.rb', line 26 def (_format) {} end |
#output_file(file_suffix) ⇒ Object
37 38 39 |
# File 'lib/bpl/derivatives/processors/shell_based_processor.rb', line 37 def output_file(file_suffix) Dir::Tmpname.create(['sufia', ".#{file_suffix}"], BPL::Derivatives.temp_file_base) {} end |
#process ⇒ Object
17 18 19 20 21 22 |
# File 'lib/bpl/derivatives/processors/shell_based_processor.rb', line 17 def process format = directives[:format] raise ArgumentError, "You must provide the :format you want to transcode into. You provided #{directives}" unless format # TODO: if the source is in the correct format, we could just copy it and skip transcoding. encode_file(format, (format)) end |