Message/Body/Delayed.pm

filter: Statementstmt 96.2% 51 / 53 Branchbran 62.5% 5 / 8 Conditioncond 50.0% 3 / 6 MC/DCmcdc 25.0% 1 / 4 Subroutinesub 100% 20 / 20 Podpod 81.8% 9 / 11 totaltotal 87.2% 89 / 102 CC 7 SCAR 4.8
CC
7
Cov
88%
modified
3.0
nrLines
2.5
string_unless_carp
2.5
CRAP 1.6
« Box/Tie.pm ↑ Summary Message/Dummy.pm »
1 # This code is part of Perl distribution Mail-Box version 4.02.
2 # The POD got stripped from this file by OODoc version 3.06.
3 # For contributors see file ChangeLog.
4  
5 # This software is copyright (c) 2001-2026 by Mark Overmeer.
6  
7 # This is free software; you can redistribute it and/or modify it under
8 # the same terms as the Perl 5 programming language system itself.
9 # SPDX-License-Identifier: Artistic-1.0-Perl OR GPL-1.0-or-later
10  
11  
12 package Mail::Message::Body::Delayed;{
13 28 our $VERSION = '4.02';
14 }
15  
16 28 ▶use parent 'Mail::Reporter';
Subroutine BEGIN: called CC=1 SCAR=0.0
17  
18 28 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
19 28 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
20  
21 28 ▶use Log::Report 'mail-box', import => [ qw/__x error/ ];
Subroutine BEGIN: called CC=1 SCAR=0.0
22  
23 use Object::Realize::Later
24 28 ▶ becomes => 'Mail::Message::Body',
Subroutine BEGIN: called CC=1 SCAR=0.0
25 realize => 'load',
26 warn_realization => 0,
27 28 believe_caller => 1;
28  
29 28 ▶use Scalar::Util qw/weaken/;
Subroutine BEGIN: called CC=1 SCAR=0.0
30  
31 #--------------------
32  
33 use overload
34 28 ▶ '""' => 'string_unless_carp',
Subroutine BEGIN: called CC=1 SCAR=0.0
35 4561 ▶ bool => sub {1},
Subroutine __ANON__: called CC=1 SCAR=0.0
36 28 ▶ '@{}' => sub { $_[0]->load->lines };
Subroutine __ANON__: called CC=1 SCAR=0.0
37  
38 #--------------------
39  
40 sub init($)
41 1486 ▶{ my ($self, $args) = @_;
Subroutine init: called CC=2 SCAR=7.0
Pod undocumented
42 1486 $self->SUPER::init($args);
43  
44 1486 $self->{MMB_seqnr} = -1; # for overloaded body comparison
45 $self->{MMBD_message} = $args->{message}
46 1486 ▶ or error __x"a message must be specified to a delayed body.";
Branch: 1 branch
BranchTrueFalseTotal
$self->{"MMBD_message"} = $args->{"message"} or &error(&__x("a message must be specified to a delayed body.")) 1486 0 1486
47  
48 1486 weaken($self->{MMBD_message});
49 1486 $self;
50 }
51  
52 #--------------------
53  
54 1539 ▶sub message() { $_[0]->{MMBD_message} }
Subroutine message: called CC=1 SCAR=0.0
Pod documented
55  
56 #--------------------
57  
58 sub modified(;$)
59 859 ▶{ return 0 if @_==1 || !$_[1];
Subroutine modified: called CC=3 SCAR=11.1
Pod documented
Branch: 1 branch
BranchTrueFalseTotal
if @_ == 1 or not $_[1] 858 1 859
Condition66%2/3
@_ == 1 or not $_[1]
l!l&&r!l&&!r
08581
MC/DC50%1/2
@_ == 1 or not $_[1]
@_ == 1 not $_[1]
Truth table66%2/3
A or not(B)
A= @_ == 1B= not $_[1]
ABresult
1X1
011
000
60 1 shift->forceRealize(shift);
61 }
62  
63  
64 sub isModified() { 0 }
65 sub isDelayed() { 1 }
66 1 ▶sub isMultipart() { $_[0]->message->head->isMultipart }
Subroutine isMultipart: called CC=1 SCAR=0.0
Pod documented
67 135 ▶sub guessSize() { $_[0]->{MMBD_size} }
Subroutine guessSize: called CC=1 SCAR=0.0
Pod documented
68  
69  
70 90 ▶sub nrLines() { $_[0]->{MMBD_lines} // $_[0]->forceRealize->nrLines }
Subroutine nrLines: called CC=2 SCAR=9.2
Pod documented
Condition33%1/3
$_[0]{"MMBD_lines"} // $_[0]->forceRealize->nrLines
l!l&&r!l&&!r
9000
MC/DC0%0/2
$_[0]{"MMBD_lines"} // $_[0]->forceRealize->nrLines
$_[0]{"MMBD_lines"} $_[0]->forceRealize->nrLines
Truth table33%1/3
A // B
A= $_[0]{"MMBD_lines"}B= $_[0]->forceRealize->nrLines
ABresult
1X1
011
000
71  
72 sub string_unless_carp()
73 80 ▶{ my $self = shift;
Subroutine string_unless_carp: called CC=2 SCAR=9.2
Pod undocumented
74 80 ▶ return $self->load->string if (caller)[0] ne 'Carp';
Branch: 1 branch
BranchTrueFalseTotal
if (caller)[0] ne "Carp" 80 0 80
75  
76 0 my $class = ref $self =~ s/^Mail::Message/MM/gr;
77 0 "$class object";
78 }
79  
80 #--------------------
81  
82 sub read($$;$@)
83 749 ▶{ my ($self, $parser, $head, $bodytype) = splice @_, 0, 4;
Subroutine read: called CC=1 SCAR=0.0
Pod documented
84 749 $self->{MMBD_parser} = $parser;
85  
86 749 @$self{ qw/MMBD_begin MMBD_end MMBD_size MMBD_lines/ } = $parser->bodyDelayed(@_);
87 749 $self;
88 }
89  
90  
91 346 ▶sub fileLocation(;@) {
Subroutine fileLocation: called CC=2 SCAR=7.2
Pod documented
92 346 my $self = shift;
93 346 ▶ @_ ? (@$self{ qw/MMBD_begin MMBD_end/ } = @_) : @$self{ qw/MMBD_begin MMBD_end/ };
Branch: 1 branch
BranchTrueFalseTotal
@_ ? : 0 346 346
94 }
95  
96  
97 sub moveLocation($)
98 134 ▶{ my ($self, $dist) = @_;
Subroutine moveLocation: called CC=1 SCAR=0.0
Pod documented
99 134 $self->{MMBD_begin} -= $dist;
100 134 $self->{MMBD_end} -= $dist;
101 134 $self;
102 }
103  
104  
105 176 ▶sub load() { $_[0] = $_[0]->message->loadBody }
Subroutine load: called CC=1 SCAR=0.0
Pod documented
106  
107 28 1;
« Box/Tie.pm ↑ Summary Message/Dummy.pm »