Skip to content
This repository has been archived by the owner on Jun 16, 2020. It is now read-only.

Commit

Permalink
More work on the check_files script
Browse files Browse the repository at this point in the history
Very much a work in progress, but I'm out of time for the day.

#59
  • Loading branch information
vmbrasseur committed May 31, 2014
1 parent e66a847 commit 9696df8
Showing 1 changed file with 42 additions and 14 deletions.
56 changes: 42 additions & 14 deletions scripts/check_files.pl
Original file line number Diff line number Diff line change
Expand Up @@ -2,34 +2,62 @@

use strict;
use warnings;

use 5.10.1;
use autodie;

use YAML qw/ LoadFile /;
use Text::CSV;
use Data::Dumper;

my $yamlfile = "../Perl_Companies.yaml";
my $csvfile = "../Perl_Companies.csv";
my $mdfile = "../PerlCompanies.md";

my $csvout = Text::CSV->new({
binary => 1,
auto_diag => 1,
allow_whitespace => 1,
always_quote => 1,
eol => "\n",
});

say "Loading $yamlfile entries";
my @yaml = sort { lc $a->{name} cmp lc $b->{name} }
@{ LoadFile( $yamlfile ) };

say "Loading $csvfile entries";
# TODO
my @csv = [];

say "Loading $mdfile entries";
# TODO
my @md = [];

print "Number of entries in each file type:\n";
print "YAML: ". scalar(@yaml) . "\n";
print "CSV: " . scalar(@csv) . "\n";
print "Markdown: " . scalar(@md) . "\n";
say "Number of entries in each file type:";
say "\tYAML: ". scalar(@yaml);
say "\tCSV: " . scalar(@csv);
say "\tMarkdown: " . scalar(@md);

if ( (scalar(@yaml) != scalar(@csv)) ||
(scalar(@yaml) != scalar(@md)) ||
(scalar(@csv) != scalar(@md))
)
{
say "The files do not match. Starting a search for errant entries.";
compare_yaml_to_csv();
compare_yaml_to_md();
compare_csv_to_md();
} else {
say "The files contain the same number of entries.";
}

# TODO
sub compare_yaml_to_csv {
say "yamltocsv";
#say Dumper($yaml[0]);
}

# TODO
sub compare_yaml_to_md {
say "yamltomd";
}

# TODO
sub compare_csv_to_md {
say "csvtomd";
}

say "Done checking.";

exit 1;

0 comments on commit 9696df8

Please sign in to comment.