blib/lib/Template/Stencil/PSGI.pm

filter: Statementstmt 100% 27 / 27 Branchbran 100% 6 / 6 Conditioncond 100% 6 / 6 MC/DCmcdc 100% 3 / 3 Subroutinesub 100% 9 / 9 Podpod 100% 4 / 4 totaltotal 100% 55 / 55 CC 7 SCAR 9.6
CC
7
Cov
100%
res
4.0
__ANON__
4.0
BEGIN
1.0
CRAP 2.6
↑ Summary blib/arch/Template/Stencil/Install/Files.pm »
1 package Template::Stencil::PSGI;
2  
3 2 ▶use 5.010;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 2 ▶use Template::Stencil;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 2 our $VERSION = '0.15';
9  
10 1 ▶sub new {
Subroutine new: called CC=1 SCAR=0.0
Pod documented
11 1 my ($class, %opts) = @_;
12 1 return bless { stencil => Template::Stencil->new(%opts) }, $class;
13 }
14  
15 1 ▶sub stencil { $_[0]{stencil} }
Subroutine stencil: called CC=1 SCAR=0.0
Pod documented
16  
17 4 ▶sub res {
Subroutine res: called CC=4 SCAR=13.9
Pod documented
18 4 my ($self, $template, $data, $status, $headers) = @_;
19 4 ▶ my $body = $self->{stencil}->render($template, $data || {});
Condition100%2/2
$data || {}
l!l
31
MC/DC100%1/1
$data || {}
$data
Truth table100%2/2
A
A= $data
Aresult
11
00
20 return [ $status || 200,
21 [ 'Content-Type' => 'text/html; charset=utf-8',
22 'Content-Length' => length $body,
23 4 ▶ @{ $headers || [] } ],
Condition100%4/4
$status || 200
l!l
13
$headers || []
l!l
13
MC/DC100%1/1
$status || 200
$status
MC/DC100%1/1
$headers || []
$headers
Truth table100%2/2
A
A= $status
Aresult
11
00
Truth table100%2/2
A
A= $headers
Aresult
11
00
24 [ $body ] ];
25 }
26  
27 1 ▶sub to_app {
Subroutine to_app: called CC=1 SCAR=0.0
Pod documented
28 1 my ($self, $routes) = @_;
29 4 ▶ return sub {
Subroutine __ANON__: called CC=4 SCAR=13.9
30 4 my $env = shift;
31 my $r = $routes->{ $env->{PATH_INFO} }
32 4 ▶ or return [ 404, [ 'Content-Type' => 'text/plain' ],
Branch: 1 branch
BranchTrueFalseTotal
my $r = $$routes{$env->{"PATH_INFO"}} or return [404, ["Content-Type", "text/plain"], ["Not Found"]] 3 1 4
33 ['Not Found'] ];
34 3 ▶ my ($template, $data) = ref $r eq 'ARRAY' ? @$r : ($r, undef);
Branch: 1 branch
BranchTrueFalseTotal
ref $r eq 'ARRAY' ? : 2 1 3
35 3 ▶ $data = $data->($env) if ref $data eq 'CODE';
Branch: 1 branch
BranchTrueFalseTotal
if ref $data eq "CODE" 2 1 3
36 3 return $self->res($template, $data);
37 1 };
38 }
39  
40 2 1;
41  
42 __END__
↑ Summary blib/arch/Template/Stencil/Install/Files.pm »