blib/lib/Verby/Action/Template.pm

filter: Statementstmt 100% 28 / 28 Branchbran 75.0% 3 / 4 Conditioncond 33.3% 1 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 100% 8 / 8 Podpod 100% 3 / 3 totaltotal 89.5% 43 / 48 CC 4 SCAR 6.2
CC
4
Cov
91%
verify
3.5
do
2.0
BEGIN
1.0
CRAP 1.9
↑ Summary
1 #!/usr/bin/perl
2  
3 package Verby::Action::Template;
4 1 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 1 with qw/Verby::Action/;
7  
8 1 our $VERSION = "0.04";
9  
10 1 ▶use Template;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 1 ▶use Template::Constants qw( :debug );
Subroutine BEGIN: called CC=1 SCAR=0.0
12  
13 has template_options => (
14 isa => "HashRef",
15 is => "rw",
16 auto_deref => 1,
17 1 ▶ default => sub { return {
Subroutine __ANON__: called CC=1 SCAR=0.0
18 1 ABSOLUTE => 1,
19 DEBUG => DEBUG_UNDEF,
20 }},
21 1 );
22  
23 has template_object => (
24 isa => "Object",
25 is => "rw",
26 1 ▶ default => sub {
Subroutine __ANON__: called CC=1 SCAR=0.0
27 1 my $self = shift;
28 1 Template->new( $self->template_options ),
29 },
30 1 );
31  
32 2 ▶sub do {
Subroutine do: called CC=2 SCAR=6.9
Pod documented
33 2 my ( $self, $c ) = @_;
34  
35 2 my $output = $c->output;
36 2 my $template = $c->template;
37  
38 2 $c->logger->info("templating '$template' into $output");
39  
40 2 my $t = $self->template_object;
41  
42 2 ▶ $t->process($template, $self->template_vars($c), $output)
Branch: 1 branch
BranchTrueFalseTotal
$t->process($template, $self->template_vars($c), $output) or $c->logger->logdie(q[couldn't process template: ] . $t->error) 1 1 2
43 || $c->logger->logdie("couldn't process template: " . $t->error);
44 }
45  
46 2 ▶sub template_vars {
Subroutine template_vars: called CC=1 SCAR=0.0
Pod documented
47 2 my ( $self, $c ) = @_;
48 2 return { c => $c };
49 }
50  
51 1 ▶sub verify {
Subroutine verify: called CC=3 SCAR=12.5
Pod documented
52 1 my ( $self, $c ) = @_;
53  
54 1 my $output = $c->output;
55  
56 1 ▶ (defined($output) and not ref($output))
Branch: 1 branch
BranchTrueFalseTotal
defined $output && !ref($output) ? : 1 0 1
Condition33%1/3
defined $output and not ref $output
!ll&&!rl&&r
001
MC/DC0%0/2
defined $output and not ref $output
defined $output not ref $output
Truth table33%1/3
A and not(B)
A= defined $outputB= not ref $output
ABresult
0X0
100
111
57 ? -e $output
58 : undef;
59 }
60  
61 1 __PACKAGE__
62  
63 __END__
↑ Summary