blib/lib/MIME/Lite/TT.pm

filter: Statementstmt 50.0% 23 / 46 Branchbran 0.0% 0 / 10 Conditioncond 0.0% 0 / 4 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 58.3% 7 / 12 Podpod 0.0% 0 / 1 totaltotal 40.0% 30 / 75 CC 8 SCAR 27.2
CC
8
Cov
38%
new
42.0
_load
6.0
utf8_upgrade
6.0
CRAP 15.1
↑ Summary
1 package MIME::Lite::TT;
2  
3 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use vars qw($VERSION);
Subroutine BEGIN: called CC=1 SCAR=0.0
5 1 $VERSION = '0.02';
6  
7 1 ▶use MIME::Lite;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 1 ▶use Template;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 1 ▶use Carp ();
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 0 ▶sub new {
Subroutine new: not called CC=6 SCAR=37.4
Pod undocumented
12 0 my ($class, %options) = @_;
13  
14 0 %options = $class->_before_process(%options);
15  
16 0 ▶ if ( my $template = delete $options{Template} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $template = delete $options{"Template"}) 0 0 0
17 0 ▶ my $tmpl_options = delete $options{TmplOptions} || {};
Condition0%0/2
delete $options{'TmplOptions'} || {}
l!l
00
MC/DC0%0/1
delete $options{'TmplOptions'} || {}
delete $options{'TmplOptions'}
Truth table0%0/2
A
A= delete $options{'TmplOptions'}
Aresult
11
00
18 0 my %config = (ABSOLUTE => 1,
19 RELATIVE => 1,
20 %$tmpl_options,
21 );
22 0 ▶ if ( $options{TmplUpgrade}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($options{"TmplUpgrade"}) 0 0 0
23 0 $config{LOAD_TEMPLATES} = [MIME::Lite::TT::Provider->new(\%config)];
24 }
25  
26 0 my $tt = Template->new(\%config);
27 0 ▶ my $tmpl_params = delete $options{TmplParams} || {};
Condition0%0/2
delete $options{'TmplParams'} || {}
l!l
00
MC/DC0%0/1
delete $options{'TmplParams'} || {}
delete $options{'TmplParams'}
Truth table0%0/2
A
A= delete $options{'TmplParams'}
Aresult
11
00
28 $tt->process($template, $tmpl_params, \$options{Data})
29 0 ▶ or Carp::croak $tt->error;
Branch: 1 branch
BranchTrueFalseTotal
$tt->process($template, $tmpl_params, \$options{"Data"}) or Carp::croak($tt->error) 0 0 0
30 }
31  
32 0 %options = $class->_after_process(%options);
33  
34 0 MIME::Lite->new(%options);
35 }
36  
37 0 ▶sub _before_process {
Subroutine _before_process: not called CC=1 SCAR=6.9
38 0 my $class = shift;
39 0 @_;
40 }
41  
42 0 ▶sub _after_process {
Subroutine _after_process: not called CC=1 SCAR=6.9
43 0 my $class = shift;
44 0 @_;
45 }
46  
47 package MIME::Lite::TT::Provider;
48 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
49 1 ▶use base qw(Template::Provider);
Subroutine BEGIN: called CC=1 SCAR=0.0
50 0 ▶sub _load {
Subroutine _load: not called CC=2 SCAR=17.9
51 0 my $self = shift;
52 0 my ($data, $error) = $self->SUPER::_load(@_);
53 0 ▶ if(defined $data) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $data) 0 0 0
54 0 $data->{text} = utf8_upgrade($data->{text});
55 }
56 0 return ($data, $error);
57 }
58 0 ▶sub utf8_upgrade {
Subroutine utf8_upgrade: not called CC=2 SCAR=17.9
59 0 my @list = map pack('U*', unpack 'U0U*', $_), @_;
60 0 ▶ return wantarray ? @list : $list[0];
Branch: 1 branch
BranchTrueFalseTotal
wantarray ? : 0 0 0
61 }
62  
63 1 1;
64 __END__
↑ Summary