CAD-Firemen

 view release on metacpan or  search on metacpan

bin/fm_diff_cdb  view on Meta::CPAN

  print2ColsRightAligned("Found old options in ". $dbhOld->{Name},  scalar(keys(%oldOptions)), "green");
  print2ColsRightAligned("Found new options in ". $dbhNew->{Name},  scalar(keys(%newOptions)), "green");
}
else{
  my ($ref1, $ref2) = loadCDB($oldUrl, $verbose);
  %oldOptions = %{$ref1};
  my %errors1 = %{$ref2};
  ($ref1, $ref2) = loadCDB($newUrl, $verbose);
  %newOptions = %{$ref1};
  my %errors2 = %{$ref2};

  if(scalar(keys(%errors1))){
    testFailed("Load first CDB");
    if($verbose > 0){
      print "Errors while parsing ". $oldUrl .":\n";
      my @lines = sort { $a <=> $b } keys(%errors1);
      my $max = length($lines[scalar(@lines) - 1]);
      foreach my $line (@lines){
        printColored(sprintf("%". $max ."s", $line) .": ". $errors1{$line} ."\n", "red");
      }
    }
    exit 1;
  }
  if(scalar(keys(%errors2))){
    testFailed("Load second CDB");
    if($verbose > 0){
      print "Errors while parsing ". $newUrl .":\n";
      my @lines = sort { $a <=> $b } keys(%errors2);
      my $max = length($lines[scalar(@lines) - 1]);
      foreach my $line (@lines){
        printColored(sprintf("%". $max ."s", $line) .": ". $errors2{$line} ."\n", "red");
      }
    }
    exit 1;
  }
  print2ColsRightAligned("Found old options in ". $oldUrl,  scalar(keys(%oldOptions)), "green");
  print2ColsRightAligned("Found new options in ". $newUrl,  scalar(keys(%newOptions)), "green");
}

my ($ref1, $ref2, $ref3, $ref4) = compare(\%oldOptions, \%newOptions);
%addedOptions = %{$ref1};
%changedOptions = %{$ref2};
%removedOptions = %{$ref3};
%duplicatedOptions = %{$ref4};
my @duplicatedKeys = sort(keys(%duplicatedOptions));
my @removedKeys = sort(keys(%removedOptions));
my @addedKeys = sort(keys(%addedOptions));
my @changedKeys = sort(keys(%changedOptions));

if($html){
  print $htmlFileHandle "<html>\n";
  print $htmlFileHandle "  <head>\n";
  print $htmlFileHandle "    <title>Changed options from ". $oldUrl ." to ". $newUrl ."</title>\n";
  print $htmlFileHandle "    <style>\n";
  print $htmlFileHandle "      div.body {\n";
  print $htmlFileHandle "        width: 100em;\n";
  print $htmlFileHandle "        margin: 0 auto;\n";
  print $htmlFileHandle "      }\n";
  print $htmlFileHandle "\n";
  print $htmlFileHandle "      dt {\n";
  print $htmlFileHandle "        font-weight: bold;\n";
  print $htmlFileHandle "      }\n";
  print $htmlFileHandle "\n";
  print $htmlFileHandle "      dd {\n";
  print $htmlFileHandle "        margin-bottom: 1em;\n";
  print $htmlFileHandle "      }\n";
  print $htmlFileHandle "\n";
  print $htmlFileHandle "      #added dl dt {\n";
  print $htmlFileHandle "        color: #008C4F;\n";
  print $htmlFileHandle "      }\n";
  print $htmlFileHandle "      #removed dl dt {\n";
  print $htmlFileHandle "        color: #8C1C00;\n";
  print $htmlFileHandle "      }\n";
  print $htmlFileHandle "      #changed dl dt {\n";
  print $htmlFileHandle "        color: #8C8C8C;\n";
  print $htmlFileHandle "      }\n";
  print $htmlFileHandle "\n";
  print $htmlFileHandle "      dd p {\n";
  print $htmlFileHandle "        margin-top: 0;\n";
  print $htmlFileHandle "      }\n";
  print $htmlFileHandle "      li.valueDefault{\n";
  print $htmlFileHandle "        text-decoration: underline;\n";
  print $htmlFileHandle "      }\n";
  print $htmlFileHandle "\n";
  print $htmlFileHandle "      thead tr td {\n";
  print $htmlFileHandle "        font-weight: bold;\n";
  print $htmlFileHandle "      }\n";
  print $htmlFileHandle "\n";
  print $htmlFileHandle "      #content {\n";
  print $htmlFileHandle "        border-spacing: 0;\n";
  print $htmlFileHandle "      }\n";
  print $htmlFileHandle "      #content td {\n";
  print $htmlFileHandle "        width: 25%;\n";
  print $htmlFileHandle "      }\n";
  print $htmlFileHandle "\n";
  print $htmlFileHandle "      td.added a {\n";
  print $htmlFileHandle "        color: #008C4F;\n";
  print $htmlFileHandle "      }\n";
  print $htmlFileHandle "      td.removed a {\n";
  print $htmlFileHandle "        color: #8C1C00;\n";
  print $htmlFileHandle "      }\n";
  print $htmlFileHandle "      td.changed a {\n";
  print $htmlFileHandle "        color: #8C8C8C;\n";
  print $htmlFileHandle "      }\n";
  print $htmlFileHandle "\n";
  print $htmlFileHandle "      a:hover {\n";
  print $htmlFileHandle "        color: #808080;\n";
  print $htmlFileHandle "        text-decoration: underline;\n";
  print $htmlFileHandle "      }\n";
  print $htmlFileHandle "\n";
  print $htmlFileHandle "      a {\n";
  print $htmlFileHandle "        color: black;\n";
  print $htmlFileHandle "        text-decoration: none;\n";
  print $htmlFileHandle "      }\n";
  print $htmlFileHandle "      .toclink {\n";
  print $htmlFileHandle "        font-weight: normal;\n";
  print $htmlFileHandle "        font-size: 10pt;\n";
  print $htmlFileHandle "      }\n";
  print $htmlFileHandle "    </style>\n";
  print $htmlFileHandle "  </head>\n";
  print $htmlFileHandle "  <body>\n";
  print $htmlFileHandle "    <div class=\"body\">\n";
  print $htmlFileHandle "      <h1>Changed options from ". $oldUrl ." to ". $newUrl ."</h1>\n";
  print $htmlFileHandle "      <a id=\"toc\"></a>\n";
  print $htmlFileHandle "      <table id=\"content\">\n";
  print $htmlFileHandle "        <thead>\n";
  print $htmlFileHandle "          <tr>\n";
  print $htmlFileHandle "            <td><a href=\"#duplicatedSection\">Duplicates (".  scalar(@duplicatedKeys) .")</a></td>\n";
  print $htmlFileHandle "            <td><a href=\"#addedSection\">Added (".  scalar(@addedKeys) .")</a></td>\n";
  print $htmlFileHandle "            <td><a href=\"#removedSection\">Removed</a> (".  scalar(@removedKeys) .")</td>\n";
  print $htmlFileHandle "            <td><a href=\"#changedSection\">Changed</a> (".  scalar(@changedKeys) .")</td>\n";
  print $htmlFileHandle "          </tr>\n";
  print $htmlFileHandle "        </thead>\n";
  print $htmlFileHandle "        <tbody>\n";
  for(my $i = 0; $i < max(scalar(@duplicatedKeys), scalar(@removedKeys), scalar(@addedKeys), scalar(@changedKeys)); $i++){
    print $htmlFileHandle "          <tr>\n";
    if($i < scalar(@duplicatedKeys)){
      print $htmlFileHandle "            <td class=\"duplicated\"><a href=\"#duplicated". $duplicatedKeys[$i] ."\">". $duplicatedKeys[$i] ."</a></td>\n";
    }
    else{
      print $htmlFileHandle "            <td></td>\n";
    }
    if($i < scalar(@addedKeys)){
      print $htmlFileHandle "            <td class=\"added\"><a href=\"#added". $addedKeys[$i] ."\">". $addedKeys[$i] ."</a></td>\n";
    }
    else{



( run in 1.610 second using v1.01-cache-2.11-cpan-39bf76dae61 )