blib/lib/Plack/Middleware/DiePretty.pm

filter: Statementstmt 100% 40 / 40 Branchbran 75.0% 3 / 4 Conditioncond 62.5% 5 / 8 MC/DCmcdc 50.0% 2 / 4 Subroutinesub 100% 12 / 12 Podpod 100% 1 / 1 totaltotal 91.3% 63 / 69 CC 6 SCAR 10.4
CC
6
Cov
92%
call
6.1
BEGIN
1.0
BEGIN
1.0
CRAP 2.8
↑ Summary
1 package Plack::Middleware::DiePretty;
2 1 ▶use parent 'Plack::Middleware';
Subroutine BEGIN: called CC=1 SCAR=0.0
3 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 1 ▶use Plack::Util::Accessor qw(template);
Subroutine BEGIN: called CC=1 SCAR=0.0
6 1 ▶use Try::Tiny;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 1 ▶use Template;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 1 ▶use Path::Class;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 1 ▶use FindBin qw($Bin);
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 1 our $VERSION = '0.001';
12 1 $VERSION = eval $VERSION;
13  
14 3 ▶sub call {
Subroutine call: called CC=6 SCAR=18.2
Pod documented
15 3 my ($self, $env) = @_;
16  
17 3 ▶ local $SIG{__DIE__} = sub { die @_; };
Subroutine __ANON__: called CC=1 SCAR=0.0
18  
19 3 my $caught;
20 3 ▶ my $res = try { $self->app->($env); } catch { $caught = $_; [ 500, [ 'Content-Type' => 'text/plain; charset=utf-8' ], [ $caught ] ]; };
Subroutine __ANON__: called CC=1 SCAR=0.0
Subroutine __ANON__: called CC=1 SCAR=0.0
21  
22 3 ▶ my $template = file( $self->template || "$Bin/html/error.html" );
Condition100%2/2
$self->template || "$Plack::Middleware::DiePretty::Bin/html/error.html"
l!l
12
MC/DC100%1/1
$self->template || "$Plack::Middleware::DiePretty::Bin/html/error.html"
$self->template
Truth table100%2/2
A
A= $self->template
Aresult
11
00
23  
24 3 ▶ if ($caught || (ref $res eq 'ARRAY' && $res->[0] == 500)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($caught or ref $res eq "ARRAY" and $res->[0] == 500) 2 1 3
Condition50%3/6
$caught or ref $res eq "ARRAY" and $res->[0] == 500
l!l&&r!l&&!r
201
ref $res eq "ARRAY" and $res->[0] == 500
!ll&&!rl&&r
010
MC/DC33%1/3
$caught or ref $res eq "ARRAY" and $res->[0] == 500
$caught ref $res eq "ARRAY" $res->[0] == 500
Truth table50%2/4
A or B and C
A= $caughtB= ref $res eq "ARRAY"C= $res->[0] == 500
ABCresult
1XX1
0111
00X0
0100
25 2 ▶ Template->new({ INCLUDE_PATH => $template->dir->absolute })->process($template->basename, { caught => $caught }, \(my $html)) || die $@;
Branch: 1 branch
BranchTrueFalseTotal
"Template"->new({"INCLUDE_PATH", $template->dir->absolute})->process($template->basename, {"caught", $caught}, \my $html) or die $@ 2 0 2
26 2 $res = [ 500, [ 'Content-Type' => 'text/html'], [ $html ] ];
27 }
28 3 $res;
29 }
30  
31 1 1;
32  
33 __END__
↑ Summary