Sisimai/Mail/STDIN.pm

filter: Statementstmt 93.3% 28 / 30 Branchbran 37.5% 3 / 8 Conditioncond 0.0% 0 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 100% 7 / 7 Podpod 100% 2 / 2 totaltotal 76.9% 40 / 52 CC 6 SCAR 16.1
CC
6
Cov
76%
read
9.0
BEGIN
1.0
BEGIN
1.0
CRAP 5.0
« Sisimai/Reason/HostUnknown.pm ↑ Summary Sisimai/Mail.pm »
1 package Sisimai::Mail::STDIN;
2 3 ▶use v5.26;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 3 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 3 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 3 ▶use IO::Handle;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 3 ▶use Class::Accessor::Lite (
Subroutine BEGIN: called CC=1 SCAR=0.0
7 3 'new' => 0,
8 'ro' => [
9 'path', # [String] Fixed string "<STDIN>"
10 'size', # [Integer] Data size which has been read
11 ],
12 'rw' => [
13 'offset', # [Integer] The number of emails which have been read
14 'handle', # [IO::File] File handle
15 ]
16 3 );
17  
18 3 ▶sub new {
Subroutine new: called CC=1 SCAR=0.0
Pod documented
19 # Constructor of Sisimai::Mail::STDIN
20 # @return [Sisimai::Mail::STDIN] Object
21 3 my $class = shift;
22 3 my $param = {
23 'path' => '<STDIN>',
24 'size' => 0,
25 'offset' => 0,
26 'handle' => IO::Handle->new->fdopen(fileno(STDIN), 'r'),
27 };
28 3 return bless($param, __PACKAGE__);
29 }
30  
31 1 ▶sub read {
Subroutine read: called CC=6 SCAR=21.9
Pod documented
32 # Mbox reader, works as an iterator.
33 # @return [String] Contents of mbox
34 1 ▶ my $self = shift; return "" unless -T $self->{'handle'};
Branch: 1 branch
BranchTrueFalseTotal
unless -T $self->{"handle"} 0 1 1
35 1 my $readhandle = $self->{'handle'};
36 1 my $readbuffer = '';
37 1 eval {
38 1 ▶ $readhandle = $self->{'handle'}->fdopen(fileno(STDIN), 'r') unless eof $readhandle;
Branch: 1 branch
BranchTrueFalseTotal
unless eof $readhandle 0 1 1
39  
40 1 ▶ while( my $r = <$readhandle> ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined(my $r = readline $readhandle)) 0 1 1
41 # Read an email from the mailbox file
42 0 ▶ last if( $readbuffer && substr($r, 0, 5) eq 'From ' );
Branch: 1 branch
BranchTrueFalseTotal
if $readbuffer and substr($r, 0, 5) eq "From " 0 0 0
Condition0%0/3
$readbuffer and substr($r, 0, 5) eq "From "
!ll&&!rl&&r
000
MC/DC0%0/2
$readbuffer and substr($r, 0, 5) eq "From "
$readbuffer substr($r, 0, 5) eq "From "
Truth table0%0/3
A and B
A= $readbufferB= substr($r, 0, 5) eq "From "
ABresult
0X0
100
111
43 0 $readbuffer .= $r;
44 }
45 };
46 1 $self->{'size'} += length $readbuffer;
47 1 $self->{'offset'} += 1;
48 1 return $readbuffer;
49 }
50  
51 3 1;
52 __END__
« Sisimai/Reason/HostUnknown.pm ↑ Summary Sisimai/Mail.pm »