LRpt
view release on metacpan or search on metacpan
lib/LRpt/CSVEADiff.pm view on Meta::CPAN
Row key defined in command line as one string. Don't use it. I will probably
get read of this switch in future
=item --keys_file=file
Name of the file containing row keys definitions
=item --cmp_rules=$cmp_rules
Name of a file containing comparing rules.
=item --log_file=$log_file
Name of a file to which log messages should be written
=item --expectations=$e_file
Name of a file containing expectations
=item --help
Prints help screen.
=item actual_dir
A file name or a directory containing I<actual> state.
=back
=cut
use vars qw( @EXPORT @ISA );
@ISA = qw( Exporter );
@EXPORT = qw( ea_diff );
my $rkeys_rdr = "";
my %actual_colls = ();
my %expected_colls = ();
=head1 METHODS
In this sections you will find a more or less complete listing of all
methods provided by the package.
=cut
############################################################################
=head2 C<ea_diff>
ea_diff( @ARGV );
Main function. @ARGV is processes by standard Getopt::Long module. Meaning
of each switch is given in L<SYNOPSIS|"SYNOPSIS">.
=cut
#############################################################################
sub ea_diff
{
local ( @ARGV ) = @_;
my @key = ();
my @key_cols = ();
my $keys_file = "";
my $cmp_rules = "";
my $global_keys = "";
my $exp_file = "";
my $log_file = "";
my $help = "";
GetOptions( "key=s" => \@key,
"key_cols=s" => \@key_cols,
"keys_file=s" => \$keys_file,
"global_keys" => \$global_keys,
"cmp_rules=s" => \$cmp_rules,
"log_file=s" => \$log_file,
"expectations=s" => \$exp_file,
"help" => \$help );
if( $help ){
print_usage();
}
$rkeys_rdr = LRpt::RKeysRdr->new( 'fname' => $keys_file,
'key' => \@key,
'key_cols' => \@key_cols,
'global_keys' => $global_keys );
load_csvs();
load_expectations( $exp_file );
compare( $cmp_rules, $log_file );
}
############################################################################
=head2 C<load_expectations>
load_expectations( $exp_file );
Loads expecations from the file C<$exp_file>.
=cut
#############################################################################
sub load_expectations
{
my $exp_file = shift;
my $exp = XMLin( $exp_file, 'forcearray' => [ 'row' ],
'keyattr' => [] );
foreach my $select ( keys %$exp ){
my @rows = ();
foreach my $row ( @{ $exp->{ $select }->{ 'row' } } ){
push( @rows, $row );
}
my $coll = LRpt::Collection->new_empty_copy(
'src_coll' => $actual_colls{ $select },
'chunk_size' => 0 );
$coll->adopt_rows( \@rows );
$expected_colls{ $select } = $coll;
}
return;
}
( run in 3.361 seconds using v1.01-cache-2.11-cpan-a49fcb8fa48 )