blib/lib/Text/Xatena/LineScanner.pm

filter: Statementstmt 97.3% 36 / 37 Branchbran 87.5% 7 / 8 Conditioncond 100% 3 / 3 MC/DCmcdc 100% 2 / 2 Subroutinesub 88.8% 8 / 9 Podpod 0.0% 0 / 7 totaltotal 84.8% 56 / 66 CC 6 SCAR 9.7
CC
6
Cov
96%
scan_until
5.0
scan
2.0
current
2.0
CRAP 2.6
« lib/Text/Xatena/Node/Table.pm ↑ Summary lib/Text/Xatena/Node/DefinitionList.pm »
1 package Text::Xatena::LineScanner;
2  
3 20 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 20 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 141 ▶sub new {
Subroutine new: called CC=1 SCAR=0.0
Pod undocumented
7 141 my ($class, $str) = @_;
8 141 my $lines = [ split /\n/, $str ];
9 141 bless {
10 matched => undef,
11 line => 0,
12 eos => !@$lines,
13 lines => $lines,
14 }, $class;
15 }
16  
17 4873 ▶sub scan {
Subroutine scan: called CC=2 SCAR=6.9
Pod undocumented
18 4873 my $self = shift;
19 4873 ▶ if (my @matched = ($self->{lines}->[$self->{line}] =~ $_[0])) {
Branch: 1 branch
BranchTrueFalseTotal
if (my(@matched) = $self->{'lines'}[$self->{'line'}] =~ /$_[0]/) { } 224 4649 4873
20 224 unshift @matched, $self->{lines}->[$self->{line}];
21 224 $self->{matched} = \@matched;
22 224 $self->{line}++;
23 224 $self->{eos} = ($self->{line} >= @{ $self->{lines} });
24 224 $matched[0];
25 } else {
26 4649 undef $self->{matched};
27 }
28 }
29  
30 274 ▶sub next {
Subroutine next: called CC=1 SCAR=0.0
Pod undocumented
31 274 my $self = shift;
32 274 my $ret = $self->{lines}->[$self->{line}];
33 274 $self->{line}++;
34 274 $self->{eos} = ($self->{line} >= @{ $self->{lines} });
35 274 $ret;
36 }
37  
38 22 ▶sub scan_until {
Subroutine scan_until: called CC=5 SCAR=16.1
Pod undocumented
39 22 my $self = shift;
40 22 my $ret = [];
41 22 ▶ until ($self->{eos} || $self->scan($_[0])) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->{"eos"} or $self->scan($_[0])) 68 22 90
Condition100%3/3
$self->{"eos"} or $self->scan($_[0])
l!l&&r!l&&!r
12168
MC/DC100%2/2
$self->{"eos"} or $self->scan($_[0])
$self->{"eos"} $self->scan($_[0])
Truth table100%3/3
A or B
A= $self->{"eos"}B= $self->scan($_[0])
ABresult
1X1
011
000
42 68 push @$ret, $self->{lines}->[$self->{line}];
43 68 $self->{line}++;
44 68 $self->{eos} = ($self->{line} >= @{ $self->{lines} });
45 }
46 22 ▶ push @$ret, $self->{matched}->[0] if $self->{matched};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"matched"} 21 1 22
47 22 ▶ wantarray? @$ret : $ret;
Branch: 1 branch
BranchTrueFalseTotal
wantarray ? : 0 22 22
48 }
49  
50 315 ▶sub matched {
Subroutine matched: called CC=1 SCAR=0.0
Pod undocumented
51 315 $_[0]->{matched};
52 }
53  
54 0 ▶sub current {
Subroutine current: not called CC=1 SCAR=6.9
Pod undocumented
55 0 $_[0]->{lines}->[$_[0]->{line}];
56 }
57  
58 648 ▶sub eos {
Subroutine eos: called CC=1 SCAR=0.0
Pod undocumented
59 $_[0]->{eos}
60 648 }
61  
62 20 1;
63 __END__
« lib/Text/Xatena/Node/Table.pm ↑ Summary lib/Text/Xatena/Node/DefinitionList.pm »