Box/File/Message.pm

filter: Statementstmt 22.6% 17 / 75 Branchbran 0.0% 0 / 16 Conditioncond 0.0% 0 / 6 MC/DCmcdc 0.0% 0 / 4 Subroutinesub 31.2% 5 / 16 Podpod 81.8% 9 / 11 totaltotal 24.2% 31 / 128 CC 13 SCAR 19.8
CC
13
Cov
18%
write
12.0
fromLine
12.0
readFromParser
12.0
CRAP 7.2
« Box/Collection.pm ↑ Summary Box/Tie/HASH.pm »
1 # Copyrights 2001-2020 by [Mark Overmeer].
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.02.
5 # This code is part of distribution Mail-Box. 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::Box::File::Message;
10 25 ▶use vars '$VERSION';
Subroutine BEGIN: called CC=1 SCAR=0.0
11 25 $VERSION = '3.009';
12  
13 25 ▶use base 'Mail::Box::Message';
Subroutine BEGIN: called CC=1 SCAR=0.0
14  
15 25 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
16 25 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
17  
18 25 ▶use List::Util qw/sum/;
Subroutine BEGIN: called CC=1 SCAR=0.0
19  
20  
21 sub init($)
22 0 ▶{ my ($self, $args) = @_;
Subroutine init: not called CC=2 SCAR=17.9
Pod undocumented
23 0 $self->SUPER::init($args);
24  
25 $self->fromLine($args->{from_line})
26 0 ▶ if exists $args->{from_line};
Branch: 1 branch
BranchTrueFalseTotal
if exists $args->{"from_line"} 0 0 0
27  
28 0 $self;
29 }
30  
31 sub coerce($)
32 0 ▶{ my ($self, $message) = @_;
Subroutine coerce: not called CC=2 SCAR=17.9
Pod documented
33 0 ▶ return $message if $message->isa(__PACKAGE__);
Branch: 1 branch
BranchTrueFalseTotal
if $message->isa(__PACKAGE__) 0 0 0
34 0 $self->SUPER::coerce($message)->labelsToStatus;
35 }
36  
37  
38 sub write(;$)
39 0 ▶{ my $self = shift;
Subroutine write: not called CC=3 SCAR=24.8
Pod documented
40 0 ▶ my $out = shift || select;
Condition0%0/3
shift() || select()
l!l&&r!l&&!r
000
MC/DC0%0/2
shift() || select()
shift() select()
Truth table0%0/3
A || B
A= shift()B= select()
ABresult
1X1
011
000
41  
42 0 my $escaped = $self->escapedBody;
43 0 $out->print($self->fromLine);
44  
45 0 my $size = sum 0, map {length($_)} @$escaped;
46  
47 0 my $head = $self->head;
48 0 $head->set('Content-Length' => $size);
49 0 $head->set('Lines' => scalar @$escaped);
50 0 $head->print($out);
51  
52 0 $out->print($_) for @$escaped;
53 0 $out->print("\n");
54 0 $self;
55 }
56  
57 sub clone()
58 0 ▶{ my $self = shift;
Subroutine clone: not called CC=1 SCAR=6.9
Pod documented
59 0 my $clone = $self->SUPER::clone;
60 0 $clone->{MBMM_from_line} = $self->{MBMM_from_line};
61 0 $clone;
62 }
63  
64 #-------------------------------------------
65  
66  
67 sub fromLine(;$)
68 0 ▶{ my $self = shift;
Subroutine fromLine: not called CC=3 SCAR=24.8
Pod documented
69  
70 0 ▶ $self->{MBMM_from_line} = shift if @_;
Branch: 1 branch
BranchTrueFalseTotal
if @_ 0 0 0
71 0 ▶ $self->{MBMM_from_line} ||= $self->head->createFromLine;
Condition0%0/3
$self->{"MBMM_from_line"} ||= $self->head->createFromLine
l!l&&r!l&&!r
000
MC/DC0%0/2
$self->{"MBMM_from_line"} ||= $self->head->createFromLine
$self->{"MBMM_from_line"} $self->head->createFromLine
Truth table0%0/3
A ||= B
A= $self->{"MBMM_from_line"}B= $self->head->createFromLine
ABresult
1X1
011
000
72 }
73  
74  
75 sub escapedBody()
76 0 ▶{ my @lines = shift->body->lines;
Subroutine escapedBody: not called CC=2 SCAR=17.9
Pod documented
77 0 s/^(\>*From )/>$1/ for @lines;
78 0 \@lines;
79 }
80  
81 #------------------------------------------
82  
83  
84 sub readFromParser($)
85 0 ▶{ my ($self, $parser) = @_;
Subroutine readFromParser: not called CC=3 SCAR=24.8
Pod documented
86 0 my ($start, $fromline) = $parser->readSeparator;
87 0 ▶ return unless $fromline;
Branch: 1 branch
BranchTrueFalseTotal
unless $fromline 0 0 0
88  
89 0 $self->{MBMM_from_line} = $fromline;
90 0 $self->{MBMM_begin} = $start;
91  
92 0 ▶ $self->SUPER::readFromParser($parser) or return;
Branch: 1 branch
BranchTrueFalseTotal
$self->SUPER::readFromParser($parser) or return 0 0 0
93 0 $self;
94 }
95  
96 0 ▶sub loadHead() { shift->head }
Subroutine loadHead: not called CC=1 SCAR=6.9
Pod undocumented
97  
98  
99 sub loadBody()
100 0 ▶{ my $self = shift;
Subroutine loadBody: not called CC=3 SCAR=24.8
Pod documented
101  
102 0 my $body = $self->body;
103 0 ▶ return $body unless $body->isDelayed;
Branch: 1 branch
BranchTrueFalseTotal
unless $body->isDelayed 0 0 0
104  
105 0 my ($begin, $end) = $body->fileLocation;
106 0 my $parser = $self->folder->parser;
107 0 $parser->filePosition($begin);
108  
109 0 my $newbody = $self->readBody($parser, $self->head);
110 0 ▶ unless($newbody)
Branch: 1 branch
BranchTrueFalseTotal
unless ($newbody) 0 0 0
111 0 { $self->log(ERROR => 'Unable to read delayed body.');
112 0 return;
113 }
114  
115 0 $self->log(PROGRESS => 'Loaded delayed body.');
116 0 $self->storeBody($newbody->contentInfoFrom($self->head));
117  
118 0 $newbody;
119 }
120  
121  
122 sub fileLocation()
123 0 ▶{ my $self = shift;
Subroutine fileLocation: not called CC=2 SCAR=17.9
Pod documented
124  
125 wantarray
126 ? ($self->{MBMM_begin}, ($self->body->fileLocation)[1])
127 0 ▶ : $self->{MBMM_begin};
Branch: 1 branch
BranchTrueFalseTotal
wantarray ? : 0 0 0
128 }
129  
130  
131 sub moveLocation($)
132 0 ▶{ my ($self, $dist) = @_;
Subroutine moveLocation: not called CC=1 SCAR=6.9
Pod documented
133 0 $self->{MBMM_begin} -= $dist;
134  
135 0 $self->head->moveLocation($dist);
136 0 $self->body->moveLocation($dist);
137 0 $self;
138 }
139  
140 #-------------------------------------------
141  
142 25 1;
« Box/Collection.pm ↑ Summary Box/Tie/HASH.pm »