Audit/MimeEntity.pm

filter: Statementstmt 90.3% 47 / 52 Branchbran 25.0% 2 / 8 Conditioncond 0.0% 0 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 90.0% 9 / 10 Podpod 100% 2 / 2 totaltotal 77.9% 60 / 77 CC 7 SCAR 13.5
CC
7
Cov
78%
_autotype_new
7.0
parser
6.0
BEGIN
1.0
CRAP 3.9
« Audit/MAPS.pm ↑ Summary Audit/MailInternet.pm »
1 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
2 package Mail::Audit::MimeEntity;
3 {
4 2 $Mail::Audit::MimeEntity::VERSION = '2.228';
5 }
6 # ABSTRACT: a Mail::Internet-based Mail::Audit object
7  
8 2 ▶use File::Path;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 2 ▶use Mail::Audit::Util::Tempdir;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 2 ▶use MIME::Parser;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 2 ▶use MIME::Entity;
Subroutine BEGIN: called CC=1 SCAR=0.0
12 2 ▶use Mail::Audit::MailInternet;
Subroutine BEGIN: called CC=1 SCAR=0.0
13 2 ▶use parent qw(Mail::Audit MIME::Entity);
Subroutine BEGIN: called CC=1 SCAR=0.0
14  
15 2 my $parser;
16  
17 my @to_rmdir;
18  
19 1 ▶sub _autotype_new {
Subroutine _autotype_new: called CC=6 SCAR=19.5
20 1 my $class = shift;
21 1 my $mailinternet = shift;
22 1 my $options = shift;
23  
24 1 $parser = MIME::Parser->new();
25  
26 1 $parser->ignore_errors(1);
27  
28 1 my $dir;
29 1 ▶ if ($options->{output_to_core}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($options->{'output_to_core'}) { } 0 1 1
30 0 $parser->output_to_core($options->{output_to_core});
31 } else {
32 1 $dir = Mail::Audit::Util::Tempdir->new;
33 1 $mailinternet->_log(3, "created temporary directory " . $dir->name);
34 1 $parser->output_under($dir->name);
35 }
36  
37 # MIME::Parser has options like extract_nested_messages which are set via
38 # option-methods.
39 # we'll hand them along here so that if you call Mail::Audit(mimeoptions =>
40 # { foo => 1 })
41 # the corresponding parser option is set, with $parser->foo(1).
42 1 foreach my $option (keys %$options) {
43 0 ▶ next if $option eq "output_to_core";
Branch: 1 branch
BranchTrueFalseTotal
if $option eq "output_to_core" 0 0 0
44 0 ▶ if ($parser->can($option)) { $parser->$option($options->{$option}); }
Branch: 1 branch
BranchTrueFalseTotal
if ($parser->can($option)) 0 0 0
45 }
46  
47 my $self = $parser->parse_data(
48 1 [ @{ $mailinternet->head->header }, "\n", @{ $mailinternet->body } ]
49 );
50  
51 # I am so, so sorry that this sort of thing is needed.
52 # -- rjbs, 2007-06-14
53 1 $self->{_log} = $mailinternet->{_log};
54  
55 1 ▶ unless ($options->{output_to_core}) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($options->{"output_to_core"}) 1 0 1
56 1 my $output_dir = $parser->filer->output_dir;
57 1 $mailinternet->_log(3, "outputting under $output_dir");
58 }
59  
60 # Augh! These guts are so foul and convoluted. I feel like I might as well
61 # be using guids. Whatever, this will solve the tempdir-lingers-too-long
62 # problem. -- rjbs, 2006-10-31
63 1 $self->{'__Mail::Audit::MimeEntity/tempdir'} = $dir;
64 1 bless($self, $class);
65 1 return $self;
66 }
67  
68  
69 0 ▶sub parser { $parser ||= MIME::Parser->new(); }
Subroutine parser: not called CC=2 SCAR=17.9
Pod documented
Condition0%0/3
$parser ||= "MIME::Parser"->new
l!l&&r!l&&!r
000
MC/DC0%0/2
$parser ||= "MIME::Parser"->new
$parser "MIME::Parser"->new
Truth table0%0/3
A ||= B
A= $parserB= "MIME::Parser"->new
ABresult
1X1
011
000
70  
71 1 ▶sub is_mime { 1; }
Subroutine is_mime: called CC=1 SCAR=0.0
Pod documented
72  
73 2 1;
74  
75 __END__
« Audit/MAPS.pm ↑ Summary Audit/MailInternet.pm »