Module: Hydra

Defined in:
lib/hydra/file_characterization.rb,
lib/hydra/file_characterization/version.rb

Defined Under Namespace

Modules: FileCharacterization

Class Method Summary collapse

Class Method Details

.characterize(content, filename, *tool_names) ⇒ String+

Run all of the specified tools against the given content and filename.

Parameters:

  • content (String)
    • The contents of the original file

  • filename (String)
    • The original file’s filename; Some

    characterization tools take hints from the file names

  • tool_names (Array)
    • A list of tool names available on the system

Returns:

  • (String, Array<String>)

    - String - When a single tool_name is given, returns the raw XML as a

    string
    

    Array<String> - When multiple tool_names are given, returns an equal

    length Array of XML strings
    


25
26
27
28
29
30
31
32
33
34
# File 'lib/hydra/file_characterization.rb', line 25

def characterize(content, filename, *tool_names)
  tool_outputs = []
  tool_names = Array(tool_names).flatten.compact
  FileCharacterization::ToTempFile.open(content, filename) do |f|
    tool_names.each do |tool_name|
      tool_outputs << FileCharacterization.characterize_with(tool_name, f.path)
    end
  end
  tool_names.size == 1 ? tool_outputs.first : tool_outputs
end