blib/lib/Terse/View/TT.pm

filter: Statementstmt 37.2% 16 / 43 Branchbran 0.0% 0 / 16 Conditioncond 0.0% 0 / 9 MC/DCmcdc 0.0% 0 / 3 Subroutinesub 62.5% 5 / 8 Podpod 0.0% 0 / 3 totaltotal 25.6% 21 / 82 CC 12 SCAR 43.5
CC
12
Cov
24%
render
132.0
render_template
6.0
build_view
2.0
CRAP 77.4
↑ Summary
1 package Terse::View::TT;
2  
3 1 ▶use 5.006;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 1 our $VERSION = 0.03;
7  
8 1 ▶use base qw/Terse::View/;
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 1 ▶use Template;
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 sub build_view {
13 0 ▶ my ($self, $config) = @_;
Subroutine build_view: not called CC=1 SCAR=6.9
Pod undocumented
14 $config = $self->app_config = {
15 EVAL_PERL => 0,
16 INCLUDE_PATH => 'root/src',
17 TEMPLATE_EXTENSION => 'tt',
18 CLASS => 'Template',
19 0 %{ $config }
20 };
21 0 $self->{template} = $config->{CLASS}->new($config);
22 0 return $self;
23 }
24  
25 sub render {
26 0 ▶ my ($self, $t, $data) = @_;
Subroutine render: not called CC=11 SCAR=48.8
Pod undocumented
27 0 my $template = $data->{template};
28 0 ▶ if (!$template) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($template) 0 0 0
29 0 $template = $t->response_namespace;
30 0 my $handler = $t->response_handler;
31 0 ▶ if ($template !~ m/$handler$/) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($template =~ /$handler$/) 0 0 0
32 0 $template .= '/' . $handler;
33 }
34 0 $template .= '.' . $self->app_config->TEMPLATE_EXTENSION;
35 }
36 0 ▶ unless ($template) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($template) 0 0 0
37 0 ▶ return $self->can('handle_error') ? $self->handle_error('Error - Cannot find template') : ('text/html', '<p>Error - Cannot find template</p>');
Branch: 1 branch
BranchTrueFalseTotal
$self->can('handle_error') ? : 0 0 0
38 }
39 0 ▶ $self->template->{SERVICE}->{WRAPPER} = ($data->{NO_WRAPPER} || (!$data->WRAPPER && ! $self->app_config->WRAPPER))
Branch: 1 branch
BranchTrueFalseTotal
$data->{'NO_WRAPPER'} || !($data->WRAPPER || $self->app_config->WRAPPER) ? : 0 0 0
Condition0%0/9
$data->{"NO_WRAPPER"} or not $data->WRAPPER || $self->app_config->WRAPPER
l!l&&r!l&&!r
000
$data->WRAPPER || $self->app_config->WRAPPER
l!l&&r!l&&!r
000
$data->WRAPPER || $self->app_config->WRAPPER
l!l&&r!l&&!r
000
MC/DC0%0/3
$data->{"NO_WRAPPER"} or not $data->WRAPPER || $self->app_config->WRAPPER
$data->{"NO_WRAPPER"} $data->WRAPPER $self->app_config->WRAPPER
Truth table0%0/4
A or not(B || C)
A= $data->{"NO_WRAPPER"}B= $data->WRAPPERC= $self->app_config->WRAPPER
ABCresult
1XX1
0001
01X0
0010
40 ? []
41 : [($data->WRAPPER || $self->app_config->WRAPPER) . '.' . $self->app_config->TEMPLATE_EXTENSION];
42 0 my $output = eval { $self->render_template($template, $data) };
43 0 ▶ if ($@) {
Branch: 1 branch
BranchTrueFalseTotal
if ($@) 0 0 0
44 0 ▶ return $self->can('handle_error') ? $self->handle_error($@) : ('text/html', $@);
Branch: 1 branch
BranchTrueFalseTotal
$self->can('handle_error') ? : 0 0 0
45 }
46 0 return ('text/html', $output);
47 }
48  
49 sub render_template {
50 0 ▶ my ($self, $template, $data) = @_;
Subroutine render_template: not called CC=2 SCAR=17.9
Pod undocumented
51 0 my $output;
52 0 ▶ unless ($self->template->process( $template, {%{$data}}, \$output )) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->template->process($template, {%{$data;}}, \$output)) 0 0 0
53 0 die $self->template->error;
54 }
55 0 return $output;
56 }
57  
58 1 1;
59  
60 __END__
↑ Summary