bin/genZPK in genZPK-0.1.8 vs bin/genZPK in genZPK-0.1.9

- old
+ new

@@ -52,11 +52,11 @@ rescue OptionParser::InvalidOption warn "Required parameters not set or invalid argument. Please run genZPK --help for more info." exit -1 end -dir = String(ARGV[0]).end_with?('/') ? String(ARGV[0]).chomp : String(ARGV[0]) +dir = String(ARGV[0]).end_with?('/') ? String(ARGV[0]) : String(ARGV[0]) + "/" requireCondition File.exists?(File.expand_path '~/.genZPK/checks.xml'), "Unable to locate configuration files. Please run genZPK --configure" requireCondition (File.read(File.expand_path('~/.genZPK/checks.xml')).gsub(/\s+/, "") != ""), "Configuration empty. Please run genZPK --configure" requireCondition getZdpack.not_nil?, "unable to locate zdpack executable. Please check zend server installation at /usr/local/zend/" requireCondition dir.not_nil?,"Required parameters not set or invalid argument. Please run genZPK --help for more info." @@ -207,11 +207,11 @@ if File.exists?(dir + path) contents = File.read(dir + path) fieldPasses = 0 check.each do |field, value| - if not field == "path" + if field != "path" if not configHash["definitions"]["definition"][field].nil? begin regex = /#{configHash["definitions"]["definition"][field]["regex"]["content"]}/ rescue RegexpError => e puts "Invalid regular in configuration. Please run genZPK --configure\n#{e.message}" @@ -219,20 +219,28 @@ end matchgrp = Integer(configHash["definitions"]["definition"][field]["regex"]["group"]) - 1 matches = contents.scan(regex) - if matches[0][0] == value - fieldPasses += 1 - else + if matches == [] if display.end_with? "\n" - display << "\tField Failed: #{field}\n" - display << "\t\tValue: #{matches[0][0]}\n" - display << "\t\tDefined value: #{value}\n" + display << "\tField not found in file: #{field}\n" else - display << "\n\tField Failed: #{field}\n" - display << "\t\tValue: #{matches[0][0]}\n" - display << "\t\tDefined value: #{value}\n" + display << "\n\tField not found in file: #{field}\n" + end + else + if matches[0][matchgrp] == value + fieldPasses += 1 + else + if display.end_with? "\n" + display << "\tField Failed: #{field}\n" + display << "\t\tValue: #{matches[0][0]}\n" + display << "\t\tDefined value: #{value}\n" + else + display << "\n\tField Failed: #{field}\n" + display << "\t\tValue: #{matches[0][0]}\n" + display << "\t\tDefined value: #{value}\n" + end end end else if display.end_with? "\n" display << "\tField not defined: #{field}\n" \ No newline at end of file