TimelogTxt/File.pm

filter: Statementstmt 92.5% 25 / 27 Branchbran 83.3% 15 / 18 Conditioncond 100% 9 / 9 MC/DCmcdc 100% 6 / 6 Subroutinesub 100% 4 / 4 Podpod 100% 2 / 2 totaltotal 92.4% 61 / 66 CC 13 SCAR 18.9
CC
13
Cov
91%
readline
8.0
new
6.7
BEGIN
1.0
CRAP 6.6
« TimelogTxt/Stack.pm ↑ Summary TimelogTxt/Day.pm »
1 package App::TimelogTxt::File;
2  
3 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 2 our $VERSION = '0.22';
7  
8 14 ▶sub new {
Subroutine new: called CC=6 SCAR=19.0
Pod documented
9 14 my ($class, $fh, $start, $end) = @_;
10  
11 14 ▶ die "Missing required file handle or file name.\n" unless defined $fh;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $fh 1 13 14
12 13 ▶ die "Missing required start marker.\n" unless defined $start;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $start 1 12 13
13 12 ▶ die "Missing required end marker.\n" unless defined $end;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $end 1 11 12
14 11 ▶ if( !ref $fh ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (ref $fh) 0 11 11
15 0 my $name = $fh;
16 0 ▶ open( $fh, '<', $name ) or die "Unable to open file '$name': $!\n";
Branch: 1 branch
BranchTrueFalseTotal
open $fh, "<", $name or die "Unable to open file '${name}': $!\n" 0 0 0
17 }
18  
19 11 my $obj = {
20 fh => $fh,
21 start => $start,
22 startlen => length $start,
23 end => $end,
24 endlen => length $end,
25 stage => 0,
26 };
27  
28 11 return bless $obj, $class;
29 }
30  
31 43 ▶sub readline {
Subroutine readline: called CC=8 SCAR=20.8
Pod documented
32 43 my ($self) = @_;
33  
34 43 ▶ return if $self->{'stage'} > 1 or eof( $self->{'fh'} );
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"stage"} > 1 or eof $self->{"fh"} 8 35 43
Condition100%3/3
$self->{"stage"} > 1 or eof $self->{"fh"}
l!l&&r!l&&!r
6235
MC/DC100%2/2
$self->{"stage"} > 1 or eof $self->{"fh"}
$self->{"stage"} > 1 eof $self->{"fh"}
Truth table100%3/3
A or B
A= $self->{"stage"} > 1B= eof $self->{"fh"}
ABresult
1X1
011
000
35  
36 35 my $line;
37 35 ▶ if( $self->{'stage'} == 0 )
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'stage'} == 0) { } 11 24 35
38 {
39 11 ▶ 0 while( defined( $line = readline $self->{'fh'} ) && substr( $line, 0, $self->{'startlen'} ) lt $self->{'start'} );
Branch: 1 branch
BranchTrueFalseTotal
defined($line = CORE::readline $self->{"fh"}) and substr($line, 0, $self->{"startlen"}) lt $self->{"start"} and do { '???' } 103 11 114
Condition100%3/3
defined($line = CORE::readline $self->{"fh"}) and substr($line, 0, $self->{"startlen"}) lt $self->{"start"}
!ll&&!rl&&r
110103
MC/DC100%2/2
defined($line = CORE::readline $self->{"fh"}) and substr($line, 0, $self->{"startlen"}) lt $self->{"start"}
defined($line = CORE::readline $self->{"fh"}) substr($line, 0, $self->{"startlen"}) lt $self->{"start"}
Truth table100%3/3
A and B
A= defined($line = CORE::readline $self->{"fh"})B= substr($line, 0, $self->{"startlen"}) lt $self->{"start"}
ABresult
0X0
100
111
40 11 $self->{'stage'} = 1;
41 }
42 else
43 {
44 24 $line = readline $self->{'fh'};
45 }
46  
47 35 ▶ return $line if !defined $line || substr( $line, 0, $self->{'endlen'} ) lt $self->{'end'};
Branch: 1 branch
BranchTrueFalseTotal
if not defined $line or substr($line, 0, $self->{"endlen"}) lt $self->{"end"} 26 9 35
Condition100%3/3
not defined $line or substr($line, 0, $self->{"endlen"}) lt $self->{"end"}
l!l&&r!l&&!r
1259
MC/DC100%2/2
not defined $line or substr($line, 0, $self->{"endlen"}) lt $self->{"end"}
not defined $line substr($line, 0, $self->{"endlen"}) lt $self->{"end"}
Truth table100%3/3
not(A) or B
A= not defined $lineB= substr($line, 0, $self->{"endlen"}) lt $self->{"end"}
ABresult
1X1
011
000
48 9 $self->{'stage'} = 2;
49 9 return;
50 }
51  
52 2 1;
53 __END__
« TimelogTxt/Stack.pm ↑ Summary TimelogTxt/Day.pm »