Sha256: 6fcb00ddc1b025adf8f890b2d79d6bdc98f32f4c8283a836d48b9ff2e46eb4ea
Contents?: true
Size: 1.65 KB
Versions: 83
Compression:
Stored size: 1.65 KB
Contents
#!/usr/bin/env ruby $:.unshift(File.expand_path(File.join(File.dirname(__FILE__), "..", "lib"))) require 'optparse' require 'ostruct' require 'recog' require 'recog/verifier_factory' options = OpenStruct.new(color: false, detail: false, quiet: false, warnings: true) option_parser = OptionParser.new do |opts| opts.banner = "Usage: #{$0} [options] XML_FINGERPRINT_FILE1 ..." opts.separator "Verifies that each fingerprint passes its internal tests." opts.separator "" opts.separator "Options" opts.on("-f", "--format FORMATTER", "Choose a formatter.", " [s]ummary (default - failure/warning msgs and summary)", " [q]uiet (configured failure/warning msgs only)", " [d]etail (fingerprint name with tests and expanded summary)") do |format| if format.start_with? 'd' options.detail = true end if format.start_with? 'q' options.quiet = true end end opts.on("-c", "--color", "Enable color in the output.") do options.color = true end opts.on("--[no-]warnings", "Track warnings") do |o| options.warnings = o end opts.on("-h", "--help", "Show this message.") do puts opts exit end end option_parser.parse!(ARGV) if ARGV.empty? $stderr.puts 'Missing XML fingerprint files' puts option_parser exit(1) end warnings = 0 failures = 0 ARGV.each do |arg| Dir.glob(arg).each do |file| ndb = Recog::DB.new(file) options.fingerprints = ndb.fingerprints verifier = Recog::VerifierFactory.build(options) verified = verifier.verify failures += verifier.reporter.failure_count warnings += verifier.reporter.warning_count end end exit failures + warnings
Version data entries
83 entries across 83 versions & 2 rubygems