Visitor.pm

filter: Statementstmt 94.2% 33 / 35 Branchbran 100% 4 / 4 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 92.3% 12 / 13 Podpod 100% 5 / 5 totaltotal 94.7% 54 / 57 SCAR 13.9
CC
4
Cov
95%
walk_parts
2.0
__ANON__
2.0
__ANON__
2.0
CRAP 4.0
« BodyMunger.pm ↑ Summary
1 3 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
2 3 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 package MIME::Visitor;
4 {
5 3 $MIME::Visitor::VERSION = '0.006';
6 }
7 # ABSTRACT: walk through MIME parts and do stuff (like rewrite)
8  
9 3 ▶use Encode;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 3 ▶use MIME::BodyMunger;
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12  
13 sub walk_parts {
14 14 ▶ my ($self, $root, $code) = @_;
Subroutine walk_parts: called CC=2 SCAR=6.9
Pod documented
15  
16 14 $code->($root);
17 14 for my $part ($root->parts) {
18 8 $self->walk_parts($part, $code);
19 }
20 }
21  
22  
23 sub walk_leaves {
24 6 ▶ my ($self, $root, $code) = @_;
Subroutine walk_leaves: called CC=1 SCAR=0.0
Pod documented
25  
26 $self->walk_parts(
27 $root,
28 sub {
29 14 ▶ return if $_[0]->is_multipart;
Subroutine __ANON__: called CC=2 SCAR=6.9
Branch: 1 branch
BranchTrueFalseTotal
if $_[0]->is_multipart 4 10 14
30 10 $code->($_[0]);
31 },
32 6 );
33 }
34  
35  
36 sub walk_text_leaves {
37 6 ▶ my ($self, $root, $code) = @_;
Subroutine walk_text_leaves: called CC=1 SCAR=0.0
Pod documented
38 $self->walk_leaves($root, sub {
39 10 ▶ return unless $_[0]->effective_type =~ qr{\Atext/(?:html|plain)(?:$|;)}i;
Subroutine __ANON__: called CC=2 SCAR=6.9
Branch: 1 branch
BranchTrueFalseTotal
unless $_[0]->effective_type =~ qr"\Atext/(?:html|plain)(?:$|;)"i 2 8 10
40 8 $code->($_[0]);
41 6 });
42 }
43  
44  
45 sub rewrite_parts {
46 1 ▶ my ($self, $root, $code) = @_;
Subroutine rewrite_parts: called CC=1 SCAR=1.2
Pod documented
47  
48 $self->walk_text_leaves($root, sub {
49 0 ▶ my ($part) = @_;
Subroutine __ANON__: not called CC=1 SCAR=6.9
50 0 MIME::BodyMunger->rewrite_content($part, $code);
51 1 });
52 }
53  
54  
55 sub rewrite_all_lines {
56 5 ▶ my ($self, $root, $code) = @_;
Subroutine rewrite_all_lines: called CC=1 SCAR=0.0
Pod documented
57  
58 $self->walk_text_leaves($root, sub {
59 8 ▶ my ($part) = @_;
Subroutine __ANON__: called CC=1 SCAR=0.0
60 8 MIME::BodyMunger->rewrite_lines($part, $code);
61 5 });
62 }
63  
64  
65 3 1;
66  
67 __END__
« BodyMunger.pm ↑ Summary