lib/DBIx/SchemaChecksum/App/ShowUpdatePath.pm

filter: Statementstmt 95.1% 39 / 41 Branchbran 56.2% 9 / 16 Conditioncond 33.3% 1 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 100% 7 / 7 Podpod n/a totaltotal 81.1% 56 / 69 CC 10 SCAR 15.7
CC
10
Cov
82%
report_file
8.1
show_update_path
6.0
run
2.3
CRAP 4.8
« lib/DBIx/SchemaChecksum/Driver/SQLite.pm ↑ Summary script/scs.pl »
1 package DBIx::SchemaChecksum::App::ShowUpdatePath;
2  
3 # ABSTRACT: Show the update path
4 2 our $VERSION = '1.106'; # VERSION
5  
6 2 ▶use 5.010;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 2 ▶use MooseX::App::Command;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 2 extends qw(DBIx::SchemaChecksum::App);
10 2 ▶use Carp qw(croak);
Subroutine BEGIN: called CC=1 SCAR=0.0
11 2 ▶use Moose::Util::TypeConstraints;
Subroutine BEGIN: called CC=1 SCAR=0.0
12  
13 2 option 'from_checksum' => ( is => 'ro', isa => 'Str',documentation => q[start update path from this checksum]
14 );
15 2 option 'output' => ( is => 'ro', default=>'nice',isa=>enum([qw[ nice concat psql ]]),);
16 2 option 'dbname' => ( is=>'ro', isa=>'Str', default=>'datebase_name');
17 2 option '+sqlsnippetdir' => ( required => 1);
18  
19 2 has '_concat' => (is=>'rw',isa=>'Str', default=>'');
20  
21 1 ▶sub run {
Subroutine run: called CC=2 SCAR=8.1
22 1 my $self = shift;
23  
24 1 ▶ $self->show_update_path( $self->from_checksum || $self->checksum );
Condition33%1/3
$self->from_checksum || $self->checksum
l!l&&r!l&&!r
010
MC/DC0%0/2
$self->from_checksum || $self->checksum
$self->from_checksum $self->checksum
Truth table33%1/3
A || B
A= $self->from_checksumB= $self->checksum
ABresult
1X1
011
000
25  
26 }
27  
28 5 ▶sub show_update_path {
Subroutine show_update_path: called CC=6 SCAR=18.0
29 5 my ($self, $this_checksum) = @_;
30 5 my $update_path = $self->_update_path;
31  
32 my $update = $update_path->{$this_checksum}
33 5 ▶ if ( exists $update_path->{$this_checksum} );
Branch: 1 branch
BranchTrueFalseTotal
if exists $update_path->{$this_checksum} 4 1 5
34  
35 5 ▶ unless ($update) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($update) 1 4 5
36 1 ▶ print "# " if $self->output eq 'psql';
Branch: 1 branch
BranchTrueFalseTotal
if $self->output eq "psql" 0 1 1
37 1 ▶ print "-- " if $self->output eq 'concat';
Branch: 1 branch
BranchTrueFalseTotal
if $self->output eq "concat" 0 1 1
38 1 say "No update found that's based on $this_checksum.";
39 1 return;
40 }
41  
42 4 ▶ if ( $update->[0] eq 'SAME_CHECKSUM' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($update->[0] eq 'SAME_CHECKSUM') { } 2 2 4
43 2 my ( $file, $post_checksum ) = splice( @$update, 1, 2 );
44 2 $self->report_file($file, $post_checksum);
45 2 $self->show_update_path($post_checksum);
46 }
47 else {
48 2 $self->report_file($update->[0],$update->[1]);
49 2 $self->show_update_path($update->[1]);
50 }
51 }
52  
53 4 ▶sub report_file {
Subroutine report_file: called CC=4 SCAR=20.9
54 4 my ($self, $file, $checksum) = @_;
55  
56 4 ▶ if ($self->output eq 'nice') {
Branch: 3 branches
BranchTrueFalseTotal
if ($self->output eq 'nice') { } 4 0 4
elsif ($self->output eq 'psql') { } 0 0 0
elsif ($self->output eq 'concat') { } 0 0 0
57 4 say $file->relative($self->sqlsnippetdir) ." ($checksum)";
58 }
59 elsif ($self->output eq 'psql') {
60 0 say 'psql '.$self->dbname.' -1 -f '.$file->relative($self->sqlsnippetdir);
61 }
62 elsif ($self->output eq 'concat') {
63 0 say "\n-- file: ".$file->relative($self->sqlsnippetdir)."\n".join('',$file->slurp)."\n";
64 }
65 }
66  
67 2 __PACKAGE__->meta->make_immutable();
68 2 1;
69  
70 __END__
« lib/DBIx/SchemaChecksum/Driver/SQLite.pm ↑ Summary script/scs.pl »