Class: Libis::Format::Cli::Format

Inherits:
SubCommand show all
Defined in:
lib/libis/format/cli/format.rb

Constant Summary collapse

DEFAULT_CONFIG =
{
    droid: true,
    fido: true,
    file: true,
    xml_validation: true
}
STRING_CONFIG =
{
    droid: 'Use Droid to identify the format',
    fido: 'Use Fido to identify the format',
    file: 'Use File to identify the format',
    xml_validation: 'When XML file found, validate the file against known XML schemas',
}

Instance Attribute Summary

Attributes included from PromptHelper

#pastel, #prompt

Instance Method Summary collapse

Methods inherited from SubCommand

banner, subcommand_prefix

Methods included from PromptHelper

#initialize

Instance Method Details

#identify(source_file) ⇒ Object



51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
# File 'lib/libis/format/cli/format.rb', line 51

def identify(source_file)
  ::Libis::Tools::Config.logger.level = :WARN
  opts = options.inject({}) { |h, x| h[x.first.to_sym] = x.last; h}
  opts[:keep_output] = true
  result = ::Libis::Format::Identifier.get source_file, opts
  puts '--- messages ---'
  result[:messages].each do |message|
    puts "#{message[0]} : #{message[1]}"
  end

  puts '--- formats ---'
  result[:formats].each do |file, info|
    puts "#{file}:"
    ap info
  end

  puts '--- tool results ---'
  result[:output].each do |file, info|
    puts "#{file}:"
    ap info
  end
end