Message/Construct/Read.pm

filter: Statementstmt 95.5% 43 / 45 Branchbran 93.7% 15 / 16 Conditioncond 33.3% 1 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 100% 5 / 5 Podpod 100% 1 / 1 totaltotal 90.2% 65 / 72 CC 10 SCAR 20.1
CC
10
Cov
92%
read
10.1
BEGIN
1.0
BEGIN
1.0
CRAP 7.5
« Message/Construct/Rebuild.pm ↑ Summary Message/Head/ResentGroup.pm »
1 # Copyrights 2001-2022 by [Mark Overmeer <markov@cpan.org>].
2 # For other contributors see ChangeLog.
3 # See the manual pages for details on the licensing terms.
4 # Pod stripped from pm file by OODoc 2.03.
5 # This code is part of distribution Mail-Message. Meta-POD processed with
6 # OODoc into POD and HTML manual-pages. See README.md
7 # Copyright Mark Overmeer. Licensed under the same terms as Perl itself.
8  
9 package Mail::Message;
10 4 ▶use vars '$VERSION';
Subroutine BEGIN: called CC=1 SCAR=0.0
11 4 $VERSION = '3.012';
12  
13  
14 4 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
15 4 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
16  
17 4 ▶use Mail::Box::FastScalar;
Subroutine BEGIN: called CC=1 SCAR=0.0
18  
19  
20 sub read($@)
21 7 ▶{ my ($class, $from, %args) = @_;
Subroutine read: called CC=10 SCAR=23.1
Pod documented
22 7 my ($filename, $file);
23 7 my $ref = ref $from;
24  
25 7 ▶ if(!$ref)
Branch: 5 branches
BranchTrueFalseTotal
if (not $ref) { } 3 4 7
elsif ($ref eq 'SCALAR') { } 1 3 4
elsif ($ref eq 'ARRAY') { } 1 2 3
elsif ($ref eq 'GLOB') { } 1 1 2
elsif ($ref and $from->isa('IO::Handle')) { } 1 0 1
26 3 { $filename = 'scalar';
27 3 $file = Mail::Box::FastScalar->new(\$from);
28 }
29 elsif($ref eq 'SCALAR')
30 1 { $filename = 'ref scalar';
31 1 $file = Mail::Box::FastScalar->new($from);
32 }
33 elsif($ref eq 'ARRAY')
34 1 { $filename = 'array of lines';
35 1 my $buffer= join '', @$from;
36 1 $file = Mail::Box::FastScalar->new(\$buffer);
37 }
38 elsif($ref eq 'GLOB')
39 1 { $filename = 'file (GLOB)';
40 1 local $/;
41 1 my $buffer= <$from>;
42 1 $file = Mail::Box::FastScalar->new(\$buffer);
43 }
44 ▶ elsif($ref && $from->isa('IO::Handle'))
Condition33%1/3
$ref and $from->isa("IO::Handle")
!ll&&!rl&&r
001
MC/DC0%0/2
$ref and $from->isa("IO::Handle")
$ref $from->isa("IO::Handle")
Truth table33%1/3
A and B
A= $refB= $from->isa("IO::Handle")
ABresult
0X0
100
111
45 1 { $filename = 'file ('.ref($from).')';
46 1 my $buffer= join '', $from->getlines;
47 1 $file = Mail::Box::FastScalar->new(\$buffer);
48 }
49 else
50 0 { $class->log(ERROR => "Cannot read from $from");
51 0 return undef;
52 }
53  
54 my $strip_status = exists $args{strip_status_fields}
55 ? delete $args{strip_status_fields}
56 7 ▶ : 1;
Branch: 1 branch
BranchTrueFalseTotal
exists $args{'strip_status_fields'} ? : 1 6 7
57  
58 7 require Mail::Box::Parser::Perl; # not parseable by C parser
59  
60 7 my $parser = Mail::Box::Parser::Perl->new
61 ( %args
62 , filename => $filename
63 , file => $file
64 , trusted => 1
65 );
66  
67 7 my $self = $class->new(%args);
68 7 $self->readFromParser($parser, $args{body_type});
69 7 $self->addReport($parser);
70  
71 7 $parser->stop;
72  
73 7 my $head = $self->head;
74 7 ▶ $head->set('Message-ID' => '<'.$self->messageId.'>')
Branch: 1 branch
BranchTrueFalseTotal
unless $head->get("Message-ID") 6 1 7
75 unless $head->get('Message-ID');
76  
77 7 ▶ $head->delete('Status', 'X-Status') if $strip_status;
Branch: 1 branch
BranchTrueFalseTotal
if $strip_status 6 1 7
78  
79 7 $self;
80 }
81  
82 4 1;
« Message/Construct/Rebuild.pm ↑ Summary Message/Head/ResentGroup.pm »