Command/verify.pm

filter: Statementstmt 28.0% 7 / 25 Branchbran 0.0% 0 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 33.3% 1 / 3 Podpod 0.0% 0 / 1 totaltotal 25.8% 8 / 31 CC 3 SCAR 20.3
CC
3
Cov
26%
run
12.0
__ANON__
1.1
BEGIN
1.0
CRAP 7.6
« Command.pm ↑ Summary Command/webload.pm »
1 package PMLTQ::Command::verify;
2 1 our $AUTHORITY = 'cpan:MATY';
3 1 $PMLTQ::Command::verify::VERSION = '2.0.3';
4 # ABSTRACT: Check if database exists and that it contains some data
5  
6 1 ▶use PMLTQ::Base 'PMLTQ::Command';
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 0 ▶has usage => sub { shift->extract_usage };
Subroutine __ANON__: not called CC=1 SCAR=1.2
9  
10 0 ▶sub run {
Subroutine run: not called CC=3 SCAR=24.8
Pod undocumented
11 0 my $self = shift;
12  
13 0 my $db_name = $self->config->{db}->{name};
14  
15 0 my $dbh;
16 0 eval { $dbh = $self->db };
17  
18 0 ▶ die "Database " . $db_name . " does not exist!\n" if $@;
Branch: 1 branch
BranchTrueFalseTotal
if $@ 0 0 0
19 0 print "Database " . $db_name . " exists\n";
20  
21 0 my @tables = map { s/^public\.//; $_ } grep {m/^public\./} $dbh->tables();
22 0 print "Database contains ", scalar @tables, " tables\n";
23 0 for my $table (@tables) {
24 0 my $sth = $dbh->prepare("SELECT * FROM $table");
25 0 $sth->execute;
26 0 print "Table $table contains " . $sth->rows . " rows\n";
27 }
28 0 $dbh->disconnect;
29 }
30  
31 =head1 SYNOPSIS
32  
33 pmltq verify <treebank_config>
34  
35 =head1 DESCRIPTION
36  
37 Check if database exists and that it contains some data.
38  
39 =head1 OPTIONS
40  
41 =head1 PARAMS
42  
43 =over 5
44  
45 =item B<treebank_config>
46  
47 Path to configuration file. If a treebank_config is --, config is readed from STDIN.
48  
49 =back
50  
51 =cut
52  
53 1 1;
« Command.pm ↑ Summary Command/webload.pm »