Courriel/Part/Multipart.pm

filter: Statementstmt 80.0% 44 / 55 Branchbran 33.3% 2 / 6 Conditioncond 66.6% 2 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 80.0% 12 / 15 Podpod 100% 4 / 4 totaltotal 75.2% 64 / 85 CC 7 SCAR 16.7
CC
7
Cov
75%
_stream_content
20.0
BUILD
4.0
is_attachment
2.0
CRAP 5.3
« Courriel.pm ↑ Summary Courriel/HeaderAttribute.pm »
1 package Courriel::Part::Multipart;
2  
3 7 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 7 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 7 ▶use namespace::autoclean;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 7 our $VERSION = '0.49';
8  
9 7 ▶use Courriel::HeaderAttribute;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 7 ▶use Courriel::Helpers qw( unique_boundary );
Subroutine BEGIN: called CC=1 SCAR=0.0
11 7 ▶use Courriel::Types qw( ArrayRef NonEmptyStr Part );
Subroutine BEGIN: called CC=1 SCAR=0.0
12 7 ▶use Email::MessageID;
Subroutine BEGIN: called CC=1 SCAR=0.0
13  
14 7 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
15 7 ▶use MooseX::StrictConstructor;
Subroutine BEGIN: called CC=1 SCAR=0.0
16  
17 7 with 'Courriel::Role::Part';
18  
19 7 has preamble => (
20 is => 'ro',
21 isa => NonEmptyStr,
22 predicate => 'has_preamble',
23 );
24  
25 7 has epilogue => (
26 is => 'ro',
27 isa => NonEmptyStr,
28 predicate => 'has_epilogue',
29 );
30  
31 7 has _parts => (
32 traits => ['Array'],
33 isa => ArrayRef [Part],
34 init_arg => 'parts',
35 required => 1,
36 handles => {
37 parts => 'elements',
38 part_count => 'count',
39 },
40 );
41  
42 40 ▶sub BUILD {
Subroutine BUILD: called CC=4 SCAR=13.9
43 40 my $self = shift;
44 40 my $p = shift;
45  
46 40 ▶ my $boundary = delete $p->{boundary} // unique_boundary;
Condition66%2/3
delete $p->{"boundary"} // unique_boundary()
l!l&&r!l&&!r
3820
MC/DC0%0/2
delete $p->{"boundary"} // unique_boundary()
delete $p->{"boundary"} unique_boundary()
Truth table66%2/3
A // B
A= delete $p->{"boundary"}B= unique_boundary()
ABresult
1X1
011
000
47 40 my $existing = $self->content_type->attribute('boundary');
48  
49 ## no critic (Subroutines::ProtectPrivateSubs)
50 40 ▶ $self->content_type->_set_attribute(
Branch: 1 branch
BranchTrueFalseTotal
$existing ? : 38 2 40
51 boundary => Courriel::HeaderAttribute->new(
52 name => ( $existing ? $existing->name : 'boundary' ),
53 value => $boundary,
54 )
55 );
56 ## use critic
57  
58 40 $_->_set_container($self) for $self->parts;
59  
60 40 return;
61 }
62  
63 0 ▶sub is_attachment {0}
Subroutine is_attachment: not called CC=1 SCAR=6.9
Pod documented
64 0 ▶sub is_inline {0}
Subroutine is_inline: not called CC=1 SCAR=6.9
Pod documented
65 2 ▶sub is_multipart {1}
Subroutine is_multipart: called CC=1 SCAR=0.0
Pod documented
66  
67 ## no critic (Subroutines::ProhibitUnusedPrivateSubroutines)
68 0 ▶sub _stream_content {
Subroutine _stream_content: not called CC=4 SCAR=30.0
69 0 my $self = shift;
70 0 my $output = shift;
71  
72 0 ▶ $output->( $self->preamble, $Courriel::Helpers::CRLF )
Branch: 1 branch
BranchTrueFalseTotal
if $self->has_preamble 0 0 0
73 if $self->has_preamble;
74  
75 0 for my $part ( $self->parts ) {
76 0 $output->(
77 $Courriel::Helpers::CRLF,
78 '--',
79 $self->boundary,
80 $Courriel::Helpers::CRLF,
81 );
82  
83 0 $part->stream_to( output => $output );
84 }
85  
86 0 $output->(
87 $Courriel::Helpers::CRLF,
88 '--',
89 $self->boundary,
90 '--',
91 $Courriel::Helpers::CRLF
92 );
93  
94 0 ▶ $output->( $self->epilogue, $Courriel::Helpers::CRLF )
Branch: 1 branch
BranchTrueFalseTotal
if $self->has_epilogue 0 0 0
95 if $self->has_epilogue;
96  
97 0 return;
98 }
99 ## use critic
100  
101 2 ▶sub boundary {
Subroutine boundary: called CC=1 SCAR=0.0
Pod documented
102 2 my $self = shift;
103  
104 2 return $self->content_type->attribute_value('boundary');
105 }
106  
107 7 __PACKAGE__->meta->make_immutable;
108  
109 7 1;
110  
111 # ABSTRACT: A part which contains other parts
112  
113 __END__
« Courriel.pm ↑ Summary Courriel/HeaderAttribute.pm »