script/dbix-dataaudit.pl untested

filter: Statementstmt 0.0% 0 / 46 Branchbran 0.0% 0 / 8 Conditioncond 0.0% 0 / 12 MC/DCmcdc 0.0% 0 / 7 Subroutinesub 0.0% 0 / 7 Podpod 0.0% 0 / 1 totaltotal 0.0% 0 / 81 CC 1 SCAR 6.9
CC
1
Cov
0%
output_xls
2.0
BEGIN
2.0
BEGIN
2.0
CRAP 2.0
1 #!/usr/local/bin/perl -w
2 use strict;
3 use DBIx::DataAudit;
4 use Getopt::Long;
5 use Pod::Usage;
6  
7 use vars '$VERSION';
8 $VERSION = '0.13';
9  
10 GetOptions(
11 'format|f:s' => \my $format,
12 'outname|o:s'=> \my $outname,
13 'where|w:s' => \my $where,
14 'dsn:s' => \my $dsn,
15 'verbose|v' => \my $verbose,
16 'help|h' => \my $display_help,
17 'man' => \my $display_man,
18 ) or pod2usage(2);
19 pod2usage(1) if $display_help;
20 pod2usage(-verbose => 2) if $display_man;
21  
22 $format ||= 'text';
23 my ($table,$traits) = @ARGV;
24 $traits ||= '';
25  
26 my @tables = split /,/, $table;
27 my @traits = split /,/, $traits;
28  
29 die "No table name given.\n"
30 unless @tables;
31  
32 my %method = (
33 'text' => sub { $_[0]->as_text },
34 'html' => sub { $_[0]->as_html },
35 'xls' => \&output_xls,
36 );
37  
38 my $wb;
39 sub output_xls {
40 require Spreadsheet::WriteExcel;
41 my ($audit) = @_;
42 $outname ||= 'dataaudit.xls';
43  
44 $wb ||= Spreadsheet::WriteExcel->new($outname);
45  
46 my $data = $audit->template_data();
47  
48 (my $name = $data->{table}) =~ s/^\w+\.//;
49 my $ws = $wb->add_worksheet($name);
50 $ws->write_row(0,0,$data->{headings});
51 $ws->write_col(1,0,$data->{rows});
52 };
53  
54 for my $table (@tables) {
55 my $audit = DBIx::DataAudit->audit(
56 dsn => $dsn,
57 table => $table,
58 traits => \@traits,
59 where => $where );
60 if ($verbose) {
61 warn $audit->get_sql . "\n";
62 };
63 print $method{$format}->($audit);
64 };
65  
66  
67 __END__