Module: Sufia::FileContent::ExtractMetadata

Includes:
Open3
Included in:
FileContentDatastream
Defined in:
lib/sufia/file_content/extract_metadata.rb

Instance Method Summary collapse

Instance Method Details

#extract_metadataObject



7
8
9
10
11
12
13
# File 'lib/sufia/file_content/extract_metadata.rb', line 7

def 
  out = nil
  to_tempfile do |f|
    out = run_fits!(f.path)
  end
  out
end

#has_content?Boolean

Return true if the content is present You can override this method if your content is an external datastream

Returns:

  • (Boolean)


33
34
35
# File 'lib/sufia/file_content/extract_metadata.rb', line 33

def has_content?
  !content.nil?
end

#to_tempfile {|f| ... } ⇒ Object

Yields:

  • (f)


15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/sufia/file_content/extract_metadata.rb', line 15

def to_tempfile &block
  return unless has_content?
  tmp_base = Sufia::Engine.config.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