| 1 | package Template::Stencil::PSGI; | ||||||||||||||||||||||
| 2 | |||||||||||||||||||||||
| 3 | 1 | ▶ | use 5.010; | ||||||||||||||||||||
|
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 | ▶ | use Template::Stencil; | ||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||
| 7 | |||||||||||||||||||||||
| 8 | 1 | our $VERSION = '0.12'; | |||||||||||||||||||||
| 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 || {}
MC/DC100%1/1
$data || {}
$data
Truth table100%2/2
A
A= $data
| |||||||||||||||||||||||
| 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
$headers || []
MC/DC100%1/1
$status || 200
$status
MC/DC100%1/1
$headers || []
$headers
Truth table100%2/2
A
A= $status
Truth table100%2/2
A
A= $headers
| |||||||||||||||||||||||
| 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
| |||||||||||||||||||||||
| 33 | ['Not Found'] ]; | ||||||||||||||||||||||
| 34 | 3 | ▶ | my ($template, $data) = ref $r eq 'ARRAY' ? @$r : ($r, undef); | ||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||
| 35 | 3 | ▶ | $data = $data->($env) if ref $data eq 'CODE'; | ||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||
| 36 | 3 | return $self->res($template, $data); | |||||||||||||||||||||
| 37 | 1 | }; | |||||||||||||||||||||
| 38 | } | ||||||||||||||||||||||
| 39 | |||||||||||||||||||||||
| 40 | 1 | 1; | |||||||||||||||||||||
| 41 | |||||||||||||||||||||||
| 42 | __END__ | ||||||||||||||||||||||