| 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::Body::String; | ||||||||||||||||||||
| 10 | 8 | ▶ | use vars '$VERSION'; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 11 | 8 | $VERSION = '3.012'; | |||||||||||||||||||
| 12 | |||||||||||||||||||||
| 13 | 8 | ▶ | use base 'Mail::Message::Body'; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 14 | |||||||||||||||||||||
| 15 | 8 | ▶ | use strict; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 16 | 8 | ▶ | use warnings; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 17 | |||||||||||||||||||||
| 18 | 8 | ▶ | use Carp; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 19 | 8 | ▶ | use Mail::Box::FastScalar; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 20 | |||||||||||||||||||||
| 21 | |||||||||||||||||||||
| 22 | #------------------------------------------ | ||||||||||||||||||||
| 23 | # The scalar is stored as reference to avoid a copy during creation of | ||||||||||||||||||||
| 24 | # a string object. | ||||||||||||||||||||
| 25 | |||||||||||||||||||||
| 26 | sub _data_from_filename(@) | ||||||||||||||||||||
| 27 | 0 | ▶ | { my ($self, $filename) = @_; | ||||||||||||||||||
|
Subroutine
_data_from_filename: not called CC=2 SCAR=17.9
| |||||||||||||||||||||
| 28 | |||||||||||||||||||||
| 29 | 0 | delete $self->{MMBS_nrlines}; | |||||||||||||||||||
| 30 | |||||||||||||||||||||
| 31 | 0 | local *IN; | |||||||||||||||||||
| 32 | 0 | ▶ | unless(open IN, '<', $filename) | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 33 | 0 | { $self->log(ERROR => | |||||||||||||||||||
| 34 | "Unable to read file $filename for message body scalar: $!"); | ||||||||||||||||||||
| 35 | 0 | return; | |||||||||||||||||||
| 36 | } | ||||||||||||||||||||
| 37 | |||||||||||||||||||||
| 38 | 0 | my @lines = <IN>; | |||||||||||||||||||
| 39 | 0 | close IN; | |||||||||||||||||||
| 40 | |||||||||||||||||||||
| 41 | 0 | $self->{MMBS_nrlines} = @lines; | |||||||||||||||||||
| 42 | 0 | $self->{MMBS_scalar} = join '', @lines; | |||||||||||||||||||
| 43 | 0 | $self; | |||||||||||||||||||
| 44 | } | ||||||||||||||||||||
| 45 | |||||||||||||||||||||
| 46 | sub _data_from_filehandle(@) | ||||||||||||||||||||
| 47 | 1 | ▶ | { my ($self, $fh) = @_; | ||||||||||||||||||
|
Subroutine
_data_from_filehandle: called CC=2 SCAR=7.8
| |||||||||||||||||||||
| 48 | 1 | ▶ | if(ref $fh eq 'Mail::Box::FastScalar') | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 49 | 0 | { my $lines = $fh->getlines; | |||||||||||||||||||
| 50 | 0 | $self->{MMBS_nrlines} = @$lines; | |||||||||||||||||||
| 51 | 0 | $self->{MMBS_scalar} = join '', @$lines; | |||||||||||||||||||
| 52 | } | ||||||||||||||||||||
| 53 | else | ||||||||||||||||||||
| 54 | 1 | { my @lines = $fh->getlines; | |||||||||||||||||||
| 55 | 1 | $self->{MMBS_nrlines} = @lines; | |||||||||||||||||||
| 56 | 1 | $self->{MMBS_scalar} = join '', @lines; | |||||||||||||||||||
| 57 | } | ||||||||||||||||||||
| 58 | 1 | $self; | |||||||||||||||||||
| 59 | } | ||||||||||||||||||||
| 60 | |||||||||||||||||||||
| 61 | sub _data_from_glob(@) | ||||||||||||||||||||
| 62 | 0 | ▶ | { my ($self, $fh) = @_; | ||||||||||||||||||
|
Subroutine
_data_from_glob: not called CC=1 SCAR=6.9
| |||||||||||||||||||||
| 63 | 0 | my @lines = <$fh>; | |||||||||||||||||||
| 64 | 0 | $self->{MMBS_nrlines} = @lines; | |||||||||||||||||||
| 65 | 0 | $self->{MMBS_scalar} = join '', @lines; | |||||||||||||||||||
| 66 | 0 | $self; | |||||||||||||||||||
| 67 | } | ||||||||||||||||||||
| 68 | |||||||||||||||||||||
| 69 | sub _data_from_lines(@) | ||||||||||||||||||||
| 70 | 1 | ▶ | { my ($self, $lines) = @_; | ||||||||||||||||||
|
Subroutine
_data_from_lines: called CC=3 SCAR=11.4
| |||||||||||||||||||||
| 71 | 1 | ▶ | $self->{MMBS_nrlines} = @$lines unless @$lines==1; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 72 | 1 | ▶ | $self->{MMBS_scalar} = @$lines==1 ? shift @$lines : join('', @$lines); | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 73 | 1 | $self; | |||||||||||||||||||
| 74 | } | ||||||||||||||||||||
| 75 | |||||||||||||||||||||
| 76 | sub clone() | ||||||||||||||||||||
| 77 | 0 | ▶ | { my $self = shift; | ||||||||||||||||||
|
Subroutine
clone: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||
| 78 | 0 | ref($self)->new(data => $self->string, based_on => $self); | |||||||||||||||||||
| 79 | } | ||||||||||||||||||||
| 80 | |||||||||||||||||||||
| 81 | sub nrLines() | ||||||||||||||||||||
| 82 | 2 | ▶ | { my $self = shift; | ||||||||||||||||||
|
Subroutine
nrLines: called CC=3 SCAR=17.3
Pod
documented
| |||||||||||||||||||||
| 83 | 2 | ▶ | return $self->{MMBS_nrlines} if defined $self->{MMBS_nrlines}; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 84 | |||||||||||||||||||||
| 85 | 0 | my $lines = $self->{MMBS_scalar} =~ tr/\n/\n/; | |||||||||||||||||||
| 86 | 0 | ▶ | $lines++ if $self->{MMBS_scalar} !~ m/\n\z/; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 87 | 0 | $self->{MMBS_nrlines} = $lines; | |||||||||||||||||||
| 88 | } | ||||||||||||||||||||
| 89 | |||||||||||||||||||||
| 90 | 2 | ▶ | sub size() { length shift->{MMBS_scalar} } | ||||||||||||||||||
|
Subroutine
size: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||
| 91 | |||||||||||||||||||||
| 92 | 3 | ▶ | sub string() { shift->{MMBS_scalar} } | ||||||||||||||||||
|
Subroutine
string: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||
| 93 | |||||||||||||||||||||
| 94 | sub lines() | ||||||||||||||||||||
| 95 | 3 | ▶ | { my @lines = split /^/, shift->{MMBS_scalar}; | ||||||||||||||||||
|
Subroutine
lines: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||
| 96 | 3 | ▶ | wantarray ? @lines : \@lines; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 97 | } | ||||||||||||||||||||
| 98 | |||||||||||||||||||||
| 99 | 0 | ▶ | sub file() { Mail::Box::FastScalar->new(\shift->{MMBS_scalar}) } | ||||||||||||||||||
|
Subroutine
file: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||
| 100 | |||||||||||||||||||||
| 101 | sub print(;$) | ||||||||||||||||||||
| 102 | 2 | ▶ | { my $self = shift; | ||||||||||||||||||
|
Subroutine
print: called CC=3 SCAR=12.3
Pod
documented
| |||||||||||||||||||||
| 103 | 2 | ▶ | my $fh = 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()
| |||||||||||||||||||||
| 104 | 2 | ▶ | if(ref $fh eq 'GLOB') { print $fh $self->{MMBS_scalar} } | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 105 | 2 | else { $fh->print($self->{MMBS_scalar}) } | |||||||||||||||||||
| 106 | 2 | $self; | |||||||||||||||||||
| 107 | } | ||||||||||||||||||||
| 108 | |||||||||||||||||||||
| 109 | sub read($$;$@) | ||||||||||||||||||||
| 110 | 0 | ▶ | { my ($self, $parser, $head, $bodytype) = splice @_, 0, 4; | ||||||||||||||||||
|
Subroutine
read: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||
| 111 | 0 | delete $self->{MMBS_nrlines}; | |||||||||||||||||||
| 112 | |||||||||||||||||||||
| 113 | 0 | (my $begin, my $end, $self->{MMBS_scalar}) = $parser->bodyAsString(@_); | |||||||||||||||||||
| 114 | 0 | $self->fileLocation($begin, $end); | |||||||||||||||||||
| 115 | |||||||||||||||||||||
| 116 | 0 | $self; | |||||||||||||||||||
| 117 | } | ||||||||||||||||||||
| 118 | |||||||||||||||||||||
| 119 | 0 | ▶ | sub endsOnNewline() { shift->{MMBS_scalar} =~ m/\A\z|\n\z/ } | ||||||||||||||||||
|
Subroutine
endsOnNewline: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||
| 120 | |||||||||||||||||||||
| 121 | 8 | 1; | |||||||||||||||||||