tt.pm

filter: Statementstmt 100% 29 / 29 Branchbran 66.6% 4 / 6 Conditioncond 50.0% 1 / 2 MC/DCmcdc 0.0% 0 / 1 Subroutinesub 100% 7 / 7 Podpod 0.0% 0 / 3 totaltotal 85.4% 41 / 48 CC 5 SCAR 10.5
CC
5
Cov
92%
pmc_compile
5.1
BEGIN
1.0
BEGIN
1.0
CRAP 2.9
↑ Summary Module/Compile/TT.pm »
1 #!/usr/bin/perl
2  
3 package tt;
4 3 ▶use Module::Compile -base;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 3 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 3 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 3 ▶use Template;
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 3 our $VERSION = "0.02";
12  
13 4 ▶sub default_tt_config {
Subroutine default_tt_config: called CC=1 SCAR=0.0
Pod undocumented
14 return (
15 4 INTERPOLATE => 0,
16 EVAL_PERL => 1,
17 INCLUDE_PATH => [ @INC ],
18 LOAD_PERL => 1,
19 DEBUG => "undef",
20 );
21 }
22  
23 4 ▶sub default_tt_vars {
Subroutine default_tt_vars: called CC=1 SCAR=0.0
Pod undocumented
24 4 my $class = shift;
25 return (
26 4 filter_class => $class,
27 'package' => undef,
28 file => undef,
29 from_line => undef,
30 to_line => undef,
31 );
32 }
33  
34 4 ▶sub pmc_compile {
Subroutine pmc_compile: called CC=5 SCAR=16.3
Pod undocumented
35 4 my ( $class, $source, $extra ) = @_;
36  
37 # try to make vars out of the use line
38 4 my %use_opts = do {
39 4 ( my $vars = $extra->{use} ) =~ s/^\s*use\s+tt\s*//;
40 4 eval "$vars";
41 };
42  
43 4 ▶ die "error evaluating vars on use line ($extra->{use}): $@"
Branch: 1 branch
BranchTrueFalseTotal
if $@ 0 4 4
44 if $@;
45  
46  
47 # try to remove keys that look like TT configuration
48 my %config = (
49 $class->default_tt_config,
50 4 map { $_ => delete $use_opts{$_} } grep /^[A-Z_]+$/, keys %use_opts,
51 );
52  
53 4 my %vars = (
54 $class->default_tt_vars,
55 %use_opts,
56 );
57  
58 4 ▶ my $t = Template->new(\%config) || die Template->error;
Condition50%1/2
'Template'->new(\%config) || die('Template'->error)
l!l
40
MC/DC0%0/1
'Template'->new(\%config) || die('Template'->error)
'Template'->new(\%config)
Truth table50%1/2
A
A= 'Template'->new(\%config)
Aresult
11
00
59  
60 4 ▶ $t->process( \$source, \%vars, \( my $out ) ) || die $t->error;
Branch: 1 branch
BranchTrueFalseTotal
$t->process(\$source, \%vars, \my $out) or die $t->error 2 2 4
61 2 ▶ $out || die $t->error;
Branch: 1 branch
BranchTrueFalseTotal
$out or die $t->error 2 0 2
62  
63 2 return $out;
64 }
65  
66 3 __PACKAGE__;
67  
68 __END__
↑ Summary Module/Compile/TT.pm »