| 1 | # Copyrights 2001-2023 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::Body::Nested; | ||||||||||||||||||||
| 10 | 34 | ▶ | use vars '$VERSION'; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 11 | 34 | $VERSION = '3.013'; | |||||||||||||||||||
| 12 | |||||||||||||||||||||
| 13 | 34 | ▶ | use base 'Mail::Message::Body'; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 14 | |||||||||||||||||||||
| 15 | 34 | ▶ | use strict; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 16 | 34 | ▶ | use warnings; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 17 | |||||||||||||||||||||
| 18 | 34 | ▶ | use Mail::Message::Body::Lines; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 19 | 34 | ▶ | use Mail::Message::Part; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 20 | |||||||||||||||||||||
| 21 | 34 | ▶ | use Carp; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 22 | |||||||||||||||||||||
| 23 | |||||||||||||||||||||
| 24 | sub init($) | ||||||||||||||||||||
| 25 | 13 | ▶ | { my ($self, $args) = @_; | ||||||||||||||||||
|
Subroutine
init: called CC=4 SCAR=14.0
Pod
undocumented
| |||||||||||||||||||||
| 26 | 13 | ▶ | $args->{mime_type} ||= 'message/rfc822'; | ||||||||||||||||||
|
Condition50%1/2
$args->{"mime_type"} ||= "message/rfc822"
MC/DC0%0/1
$args->{"mime_type"} ||= "message/rfc822"
$args->{"mime_type"}
Truth table50%1/2
A
A= $args->{"mime_type"}
| |||||||||||||||||||||
| 27 | |||||||||||||||||||||
| 28 | 13 | $self->SUPER::init($args); | |||||||||||||||||||
| 29 | |||||||||||||||||||||
| 30 | 13 | my $nested; | |||||||||||||||||||
| 31 | 13 | ▶ | if(my $raw = $args->{nested}) | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 32 | 12 | { $nested = Mail::Message::Part->coerce($raw, $self); | |||||||||||||||||||
| 33 | |||||||||||||||||||||
| 34 | 12 | ▶ | croak 'Data not convertible to a message (type is ', ref $raw,")\n" | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 35 | unless defined $nested; | ||||||||||||||||||||
| 36 | } | ||||||||||||||||||||
| 37 | |||||||||||||||||||||
| 38 | 13 | $self->{MMBN_nested} = $nested; | |||||||||||||||||||
| 39 | 13 | $self; | |||||||||||||||||||
| 40 | } | ||||||||||||||||||||
| 41 | |||||||||||||||||||||
| 42 | sub isNested() {1} | ||||||||||||||||||||
| 43 | |||||||||||||||||||||
| 44 | 0 | ▶ | sub isBinary() { shift->nested->body->isBinary } | ||||||||||||||||||
|
Subroutine
isBinary: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||
| 45 | |||||||||||||||||||||
| 46 | sub clone() | ||||||||||||||||||||
| 47 | 1 | ▶ | { my $self = shift; | ||||||||||||||||||
|
Subroutine
clone: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||
| 48 | |||||||||||||||||||||
| 49 | 1 | ref($self)->new | |||||||||||||||||||
| 50 | ( $self->logSettings | ||||||||||||||||||||
| 51 | , based_on => $self | ||||||||||||||||||||
| 52 | , nested => $self->nested->clone | ||||||||||||||||||||
| 53 | ); | ||||||||||||||||||||
| 54 | } | ||||||||||||||||||||
| 55 | |||||||||||||||||||||
| 56 | 11 | ▶ | sub nrLines() { shift->nested->nrLines } | ||||||||||||||||||
|
Subroutine
nrLines: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||
| 57 | |||||||||||||||||||||
| 58 | 13 | ▶ | sub size() { shift->nested->size } | ||||||||||||||||||
|
Subroutine
size: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||
| 59 | |||||||||||||||||||||
| 60 | sub string() | ||||||||||||||||||||
| 61 | 1 | ▶ | { my $nested = shift->nested; | ||||||||||||||||||
|
Subroutine
string: called CC=2 SCAR=7.2
Pod
documented
| |||||||||||||||||||||
| 62 | 1 | ▶ | defined $nested ? $nested->string : ''; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 63 | } | ||||||||||||||||||||
| 64 | |||||||||||||||||||||
| 65 | sub lines() | ||||||||||||||||||||
| 66 | 0 | ▶ | { my $nested = shift->nested; | ||||||||||||||||||
|
Subroutine
lines: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||
| 67 | 0 | ▶ | defined $nested ? ($nested->lines) : (); | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 68 | } | ||||||||||||||||||||
| 69 | |||||||||||||||||||||
| 70 | sub file() | ||||||||||||||||||||
| 71 | 0 | ▶ | { my $nested = shift->nested; | ||||||||||||||||||
|
Subroutine
file: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||
| 72 | 0 | ▶ | defined $nested ? $nested->file : undef; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 73 | } | ||||||||||||||||||||
| 74 | |||||||||||||||||||||
| 75 | sub print(;$) | ||||||||||||||||||||
| 76 | 3 | ▶ | { my $self = shift; | ||||||||||||||||||
|
Subroutine
print: called CC=2 SCAR=8.1
Pod
documented
| |||||||||||||||||||||
| 77 | 3 | ▶ | $self->nested->print(shift || select); | ||||||||||||||||||
|
Condition33%1/3
shift() || select()
MC/DC0%0/2
shift() || select()
shift()
select()
Truth table33%1/3
A || B
A= shift()B= select()
| |||||||||||||||||||||
| 78 | } | ||||||||||||||||||||
| 79 | |||||||||||||||||||||
| 80 | sub partNumberOf($) | ||||||||||||||||||||
| 81 | 3 | ▶ | { my ($self, $part) = @_; | ||||||||||||||||||
|
Subroutine
partNumberOf: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||
| 82 | 3 | ▶ | $self->message->partNumber || '1'; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 83 | } | ||||||||||||||||||||
| 84 | |||||||||||||||||||||
| 85 | |||||||||||||||||||||
| 86 | sub foreachLine($) | ||||||||||||||||||||
| 87 | 0 | ▶ | { my ($self, $code) = @_; | ||||||||||||||||||
|
Subroutine
foreachLine: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||
| 88 | 0 | $self->log(ERROR => "You cannot use foreachLine on a nested"); | |||||||||||||||||||
| 89 | 0 | confess; | |||||||||||||||||||
| 90 | } | ||||||||||||||||||||
| 91 | |||||||||||||||||||||
| 92 | 0 | ▶ | sub check() { shift->forNested( sub {$_[1]->check} ) } | ||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
Subroutine
check: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||
| 93 | |||||||||||||||||||||
| 94 | sub encode(@) | ||||||||||||||||||||
| 95 | 1 | ▶ | { my ($self, %args) = @_; | ||||||||||||||||||
|
Subroutine
encode: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||
| 96 | 1 | ▶ | $self->forNested( sub {$_[1]->encode(%args)} ); | ||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 97 | } | ||||||||||||||||||||
| 98 | |||||||||||||||||||||
| 99 | 7 | ▶ | sub encoded() { shift->forNested( sub {$_[1]->encoded} ) } | ||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
Subroutine
encoded: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||
| 100 | |||||||||||||||||||||
| 101 | sub read($$$$) | ||||||||||||||||||||
| 102 | 1 | ▶ | { my ($self, $parser, $head, $bodytype) = @_; | ||||||||||||||||||
|
Subroutine
read: called CC=2 SCAR=7.0
Pod
documented
| |||||||||||||||||||||
| 103 | |||||||||||||||||||||
| 104 | 1 | my $nest = Mail::Message::Part->new(container => undef); | |||||||||||||||||||
| 105 | 1 | ▶ | $nest->readFromParser($parser, $bodytype) | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 106 | or return; | ||||||||||||||||||||
| 107 | |||||||||||||||||||||
| 108 | 1 | $nest->container($self); | |||||||||||||||||||
| 109 | 1 | $self->{MMBN_nested} = $nest; | |||||||||||||||||||
| 110 | 1 | $self; | |||||||||||||||||||
| 111 | } | ||||||||||||||||||||
| 112 | |||||||||||||||||||||
| 113 | sub fileLocation() | ||||||||||||||||||||
| 114 | 0 | ▶ | { my $nested = shift->nested; | ||||||||||||||||||
|
Subroutine
fileLocation: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||
| 115 | |||||||||||||||||||||
| 116 | 0 | ( ($nested->head->fileLocation)[0] | |||||||||||||||||||
| 117 | , ($nested->body->fileLocation)[1] | ||||||||||||||||||||
| 118 | ); | ||||||||||||||||||||
| 119 | } | ||||||||||||||||||||
| 120 | |||||||||||||||||||||
| 121 | 2 | ▶ | sub endsOnNewline() { shift->nested->body->endsOnNewline } | ||||||||||||||||||
|
Subroutine
endsOnNewline: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||
| 122 | |||||||||||||||||||||
| 123 | sub moveLocation($) | ||||||||||||||||||||
| 124 | 0 | ▶ | { my $self = shift; | ||||||||||||||||||
|
Subroutine
moveLocation: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||
| 125 | 0 | my $nested = $self->nested; | |||||||||||||||||||
| 126 | 0 | ▶ | my $dist = shift or return $self; # no move | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 127 | |||||||||||||||||||||
| 128 | 0 | $nested->head->moveLocation($dist); | |||||||||||||||||||
| 129 | 0 | $nested->body->moveLocation($dist); | |||||||||||||||||||
| 130 | 0 | $self; | |||||||||||||||||||
| 131 | } | ||||||||||||||||||||
| 132 | |||||||||||||||||||||
| 133 | #------------------------- | ||||||||||||||||||||
| 134 | |||||||||||||||||||||
| 135 | 63 | ▶ | sub nested() { shift->{MMBN_nested} } | ||||||||||||||||||
|
Subroutine
nested: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||
| 136 | |||||||||||||||||||||
| 137 | |||||||||||||||||||||
| 138 | sub forNested($) | ||||||||||||||||||||
| 139 | 8 | ▶ | { my ($self, $code) = @_; | ||||||||||||||||||
|
Subroutine
forNested: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||
| 140 | 8 | my $nested = $self->nested; | |||||||||||||||||||
| 141 | 8 | my $body = $nested->body; | |||||||||||||||||||
| 142 | |||||||||||||||||||||
| 143 | 8 | ▶ | my $new_body = $code->($self, $body) | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 144 | or return; | ||||||||||||||||||||
| 145 | |||||||||||||||||||||
| 146 | 8 | ▶ | return $self if $new_body == $body; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 147 | |||||||||||||||||||||
| 148 | 4 | my $new_nested = Mail::Message::Part->new | |||||||||||||||||||
| 149 | ( head => $nested->head->clone | ||||||||||||||||||||
| 150 | , container => undef | ||||||||||||||||||||
| 151 | ); | ||||||||||||||||||||
| 152 | |||||||||||||||||||||
| 153 | 4 | $new_nested->body($new_body); | |||||||||||||||||||
| 154 | |||||||||||||||||||||
| 155 | 4 | my $created = (ref $self)->new | |||||||||||||||||||
| 156 | ( based_on => $self | ||||||||||||||||||||
| 157 | , nested => $new_nested | ||||||||||||||||||||
| 158 | ); | ||||||||||||||||||||
| 159 | |||||||||||||||||||||
| 160 | 4 | $new_nested->container($created); | |||||||||||||||||||
| 161 | 4 | $created; | |||||||||||||||||||
| 162 | } | ||||||||||||||||||||
| 163 | |||||||||||||||||||||
| 164 | 0 | ▶ | sub toplevel() { my $msg = shift->message; $msg ? $msg->toplevel : undef} | ||||||||||||||||||
|
Subroutine
toplevel: not called CC=2 SCAR=17.9
Pod
undocumented
Branch: 1 branch
| |||||||||||||||||||||
| 165 | |||||||||||||||||||||
| 166 | 34 | 1; | |||||||||||||||||||