ResponseHelper/Attachment.pm

filter: Statementstmt 100% 18 / 18 Branchbran n/a Conditioncond 40.0% 2 / 5 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 100% 5 / 5 Podpod 0.0% 0 / 1 totaltotal 80.6% 25 / 31 CC 3 SCAR 6.4
CC
3
Cov
87%
helper
3.1
BEGIN
1.0
BEGIN
1.0
CRAP 1.9
« ResponseHelper/Redirect.pm ↑ Summary ResponseHelper/JSON.pm »
1 package Plack::ResponseHelper::Attachment;
2 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 1 ▶use Plack::Response;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7  
8 1 ▶sub helper {
Subroutine helper: called CC=3 SCAR=11.3
Pod undocumented
9 1 my $init = shift;
10 1 ▶ my $content_type = $init && $init->{content_type} || 'application/octet-stream';
Condition40%2/5
$init && $init->{'content_type'} || 'application/octet-stream'
l!l
10
$init and $init->{"content_type"}
!ll&&!rl&&r
001
MC/DC0%0/2
$init && $init->{'content_type'} || 'application/octet-stream'
$init $init->{"content_type"}
Truth table33%1/3
A and B
A= $initB= $init->{"content_type"}
ABresult
111
0X0
100
11  
12 1 ▶ return sub {
Subroutine __ANON__: called CC=1 SCAR=0.0
13 1 my $r = shift;
14  
15 1 my $response = Plack::Response->new(200);
16 1 $response->headers(
17 [
18 'Content-Type' => $content_type,
19 'Content-Disposition' => qq[attachment; filename="$r->{filename}"],
20 ],
21 );
22 1 $response->body($r->{data});
23 1 return $response;
24 1 };
25 }
26  
27 1 1;
28  
29 __END__
« ResponseHelper/Redirect.pm ↑ Summary ResponseHelper/JSON.pm »