blib/lib/DBIO/Storage/Debug/PrettyTrace.pm

filter: Statementstmt 95.3% 62 / 65 Branchbran 78.5% 11 / 14 Conditioncond 81.2% 13 / 16 MC/DCmcdc 55.5% 5 / 9 Subroutinesub 100% 8 / 8 Podpod 100% 4 / 4 totaltotal 88.7% 103 / 116 CC 14 SCAR 15.4
CC
14
Cov
91%
print
8.0
new
4.0
query_start
3.3
CRAP 4.7
« blib/lib/DBIO/InflateColumn/Serializer.pm ↑ Summary blib/lib/DBIO/Relationship/Codegen.pm »
1 package DBIO::Storage::Debug::PrettyTrace;
2 # ABSTRACT: Pretty Tracing DebugObj
3  
4 5 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 5 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 5 our $VERSION = '0.900007';
8  
9 5 ▶use base 'DBIO::Storage::Statistics';
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 5 ▶use SQL::Abstract::Tree;
Subroutine BEGIN: called CC=1 SCAR=0.0
12  
13 5 __PACKAGE__->mk_group_accessors( simple => '_sqlat' );
14 5 __PACKAGE__->mk_group_accessors( simple => '_clear_line_str' );
15 5 __PACKAGE__->mk_group_accessors( simple => '_executing_str' );
16 5 __PACKAGE__->mk_group_accessors( simple => '_show_progress' );
17 5 __PACKAGE__->mk_group_accessors( simple => '_last_sql' );
18 5 __PACKAGE__->mk_group_accessors( simple => 'squash_repeats' );
19  
20  
21 3 ▶sub new {
Subroutine new: called CC=4 SCAR=13.9
Pod documented
22 3 my $class = shift;
23 3 my $args = shift;
24  
25 3 ▶ my $clear_line = $args->{clear_line} || "\r\x1b[J";
Condition100%2/2
$args->{'clear_line'} || "\r\e[J"
l!l
12
MC/DC100%1/1
$args->{'clear_line'} || "\r\e[J"
$args->{'clear_line'}
Truth table100%2/2
A
A= $args->{'clear_line'}
Aresult
11
00
26 my $executing = $args->{executing} || (
27 3 ▶ eval { require Term::ANSIColor } ? do {
Branch: 1 branch
BranchTrueFalseTotal
eval { do { require Term::ANSIColor } } ? : 2 0 2
Condition66%2/3
$args->{'executing'} || (eval { do { require Term::ANSIColor } } ? do { my $c = \&Term::ANSIColor::color; &$c('blink white on_black') . 'EXECUTING...' . &$c('reset') } : 'EXECUTING...')
l!l&&r!l&&!r
120
MC/DC0%0/2
$args->{'executing'} || (eval { do { require Term::ANSIColor } } ? do { my $c = \&Term::ANSIColor::color; &$c('blink white on_black') . 'EXECUTING...' . &$c('reset') } : 'EXECUTING...')
$args->{'executing'} (eval { do { require Term::ANSIColor } } ? do { my $c = \&Term::ANSIColor::color; &$c('blink white on_black') . 'EXECUTING...' . &$c('reset') } : 'EXECUTING...')
Truth table66%2/3
A || B
A= $args->{'executing'}B= (eval { do { require Term::ANSIColor } } ? do { my $c = \&Term::ANSIColor::color; &$c('blink white on_black') . 'EXECUTING...' . &$c('reset') } : 'EXECUTING...')
ABresult
1X1
011
000
28 2 my $c = \&Term::ANSIColor::color;
29 2 $c->('blink white on_black') . 'EXECUTING...' . $c->('reset');
30 } : 'EXECUTING...'
31 );
32 3 my $show_progress = $args->{show_progress};
33  
34 3 my $squash_repeats = $args->{squash_repeats};
35 3 my $sqlat = SQL::Abstract::Tree->new($args);
36 3 my $self = $class->next::method(@_);
37 3 $self->_clear_line_str($clear_line);
38 3 $self->_executing_str($executing);
39 3 $self->_show_progress($show_progress);
40  
41 3 $self->squash_repeats($squash_repeats);
42  
43 3 $self->_sqlat($sqlat);
44 3 $self->_last_sql('');
45  
46 3 return $self
47 }
48  
49  
50 8 ▶sub print {
Subroutine print: called CC=8 SCAR=20.8
Pod documented
51 8 my $self = shift;
52 8 my $string = shift;
53 8 ▶ my $bindargs = shift || [];
Condition50%1/2
shift() || []
l!l
80
MC/DC0%0/1
shift() || []
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
54  
55 8 my ($lw, $lr);
56 8 ($lw, $string, $lr) = $string =~ /^(\s*)(.+?)(\s*)$/s;
57  
58 8 ▶ local $self->_sqlat->{fill_in_placeholders} = 0 if defined $bindargs
Branch: 1 branch
BranchTrueFalseTotal
if defined $bindargs and defined $bindargs->[0] and $bindargs->[0] eq "'__BULK_INSERT__'" 1 7 8
Condition83%5/6
defined $bindargs and defined $bindargs->[0] and $bindargs->[0] eq "'__BULK_INSERT__'"
!ll&&!rl&&r
161
defined $bindargs and defined $bindargs->[0]
!ll&&!rl&&r
017
MC/DC66%2/3
defined $bindargs and defined $bindargs->[0] and $bindargs->[0] eq "'__BULK_INSERT__'"
defined $bindargs defined $bindargs->[0] $bindargs->[0] eq "'__BULK_INSERT__'"
Truth table75%3/4
A and B and C
A= defined $bindargsB= defined $bindargs->[0]C= $bindargs->[0] eq "'__BULK_INSERT__'"
ABCresult
0XX0
10X0
1100
1111
59 && defined $bindargs->[0] && $bindargs->[0] eq q('__BULK_INSERT__');
60  
61 8 my $use_placeholders = !!$self->_sqlat->fill_in_placeholders;
62  
63 8 my $sqlat = $self->_sqlat;
64 8 my $formatted;
65 8 ▶ if ($self->squash_repeats && $self->_last_sql eq $string) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->squash_repeats and $self->_last_sql eq $string) { } 3 5 8
Condition100%3/3
$self->squash_repeats and $self->_last_sql eq $string
!ll&&!rl&&r
233
MC/DC100%2/2
$self->squash_repeats and $self->_last_sql eq $string
$self->squash_repeats $self->_last_sql eq $string
Truth table100%3/3
A and B
A= $self->squash_repeatsB= $self->_last_sql eq $string
ABresult
0X0
100
111
66 3 my ( $l, $r ) = @{ $sqlat->placeholder_surround };
67 3 $formatted = '... : ' . join(', ', map "$l$_$r", @$bindargs)
68 } else {
69 5 $self->_last_sql($string);
70 5 $formatted = $sqlat->format($string, $bindargs);
71 5 ▶ $formatted = "$formatted : " . join ', ', @{$bindargs}
Branch: 1 branch
BranchTrueFalseTotal
unless $use_placeholders 2 3 5
72 unless $use_placeholders;
73 }
74  
75 8 $self->next::method("$lw$formatted$lr", @_);
76 }
77  
78  
79 8 ▶sub query_start {
Subroutine query_start: called CC=3 SCAR=12.0
Pod documented
80 8 my ($self, $string, @bind) = @_;
81  
82 8 ▶ if (defined $self->callback) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->callback) 0 8 8
83 0 $string =~ m/^(\w+)/;
84 0 $self->callback->($1, "$string: ".join(', ', @bind)."\n");
85 0 return;
86 }
87  
88 8 $string =~ s/\s+$//;
89  
90 8 $self->print("$string\n", \@bind);
91  
92 8 ▶ $self->debugfh->print($self->_executing_str) if $self->_show_progress
Branch: 1 branch
BranchTrueFalseTotal
if $self->_show_progress 1 7 8
93 }
94  
95  
96 1 ▶sub query_end {
Subroutine query_end: called CC=2 SCAR=7.6
Pod documented
97 1 ▶ $_[0]->debugfh->print($_[0]->_clear_line_str) if $_[0]->_show_progress
Branch: 1 branch
BranchTrueFalseTotal
if $_[0]->_show_progress 1 0 1
98 }
99  
100 5 1;
101  
102 __END__
« blib/lib/DBIO/InflateColumn/Serializer.pm ↑ Summary blib/lib/DBIO/Relationship/Codegen.pm »