class AIXM::Executables::Ckmid
Public Class Methods
new(**options)
click to toggle source
# File lib/aixm/executables.rb 45 def initialize(**options) 46 OptionParser.new do |o| 47 o.banner = <<~END 48 Check mid attributes of an OFMX file. 49 Usage: #{File.basename($0)} infile.ofmx 50 END 51 o.on('-A', '--about', 'show author/license information and exit') { AIXM::Executables.about } 52 o.on('-V', '--version', 'show version and exit') { AIXM::Executables.version } 53 end.parse! 54 @infile = ARGV.shift 55 end
Public Instance Methods
run()
click to toggle source
# File lib/aixm/executables.rb 57 def run 58 fail 'cannot read file' unless @infile && File.readable?(@infile) 59 fail 'file ist not OFMX' unless @infile.match?(/\.ofmx$/) 60 AIXM.ofmx! 61 document = File.open(@infile) { Nokogiri::XML(_1) } 62 errors = Nokogiri::XML::Schema(File.open(AIXM.schema(:xsd))).validate(document) 63 errors += AIXM::PayloadHash::Mid.new(document).check_mid 64 if errors.any? 65 puts errors 66 fail "OFMX file has errors" 67 end 68 rescue => error 69 puts "ERROR: #{error.message}" 70 exit 1 71 end