Sha256: 1c7e4eb612e438b9fea049d39bc3019ddd02cd50eb9b0bf761ee45d77187a09a
Contents?: true
Size: 1.2 KB
Versions: 2
Compression:
Stored size: 1.2 KB
Contents
require 'open3' module Hydra module Derivatives module ExtractMetadata include Open3 def extract_metadata out = nil to_tempfile do |f| out = run_fits!(f.path) end out end def to_tempfile &block return unless has_content? tmp_base = Hydra::Derivatives.temp_file_base f = Tempfile.new("#{pid}-#{dsVersionID}") f.binmode if content.respond_to? :read f.write(content.read) else f.write(content) end f.close content.rewind if content.respond_to? :rewind yield(f) f.unlink end private def run_fits!(file_path) command = "#{fits_path} -i \"#{file_path}\"" stdin, stdout, stderr, wait_thr = popen3(command) stdin.close out = stdout.read stdout.close err = stderr.read stderr.close exit_status = wait_thr.value raise "Unable to execute command \"#{command}\"\n#{err}" unless exit_status.success? out end def fits_path Hydra::Derivatives.fits_path end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
hydra-derivatives-0.0.2 | lib/hydra/derivatives/extract_metadata.rb |
hydra-derivatives-0.0.1 | lib/hydra/derivatives/extract_metadata.rb |