ZofCMS/Plugin/SendFile.pm

filter: Statementstmt 40.0% 14 / 35 Branchbran 0.0% 0 / 18 Conditioncond 0.0% 0 / 6 MC/DCmcdc 0.0% 0 / 4 Subroutinesub 66.6% 4 / 6 Podpod 0.0% 0 / 2 totaltotal 25.3% 18 / 71 CC 13 SCAR 48.8
CC
13
Cov
24%
process
182.0
new
2.0
BEGIN
1.0
CRAP 131.8
« ZofCMS/Plugin/FormMailer.pm ↑ Summary ZofCMS/Plugin/Barcode.pm »
1 package App::ZofCMS::Plugin::SendFile;
2  
3 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 1 our $VERSION = '1.001010'; # VERSION
7  
8 1 ▶use MIME::Types;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 1 ▶use File::Spec;
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 0 ▶sub new { bless {}, shift; }
Subroutine new: not called CC=1 SCAR=6.9
Pod undocumented
12  
13 0 ▶sub process {
Subroutine process: not called CC=13 SCAR=52.0
Pod undocumented
14 0 my ( $self, $t, $q, $config ) = @_;
15  
16 0 my $file = delete $t->{plug_send_file};
17  
18 $file = delete $config->conf->{plug_send_file}
19 0 ▶ unless defined $file
Branch: 1 branch
BranchTrueFalseTotal
unless defined $file and length $file 0 0 0
Condition0%0/3
defined $file and length $file
!ll&&!rl&&r
000
MC/DC0%0/2
defined $file and length $file
defined $file length $file
Truth table0%0/3
A and B
A= defined $fileB= length $file
ABresult
0X0
100
111
20 and length $file;
21  
22 0 ▶ if ( ref $file eq 'CODE' ) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $file eq "CODE") 0 0 0
23 0 $file = $file->( $t, $q, $config );
24 }
25  
26 return
27 0 ▶ unless defined $file
Branch: 1 branch
BranchTrueFalseTotal
unless defined $file and length $file 0 0 0
Condition0%0/3
defined $file and length $file
!ll&&!rl&&r
000
MC/DC0%0/2
defined $file and length $file
defined $file length $file
Truth table0%0/3
A and B
A= defined $fileB= length $file
ABresult
0X0
100
111
28 and length $file;
29  
30 0 my ( $disposition, $type, $filename );
31 0 ▶ if ( ref $file eq 'ARRAY' ) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $file eq "ARRAY") 0 0 0
32 0 ( $file, $disposition, $type, $filename ) = @$file;
33 }
34  
35 0 ▶ $filename = (File::Spec->splitdir( $file ))[-1]
Branch: 1 branch
BranchTrueFalseTotal
unless defined $filename 0 0 0
36 unless defined $filename;
37  
38 0 ▶ $disposition = 'inline'
Branch: 1 branch
BranchTrueFalseTotal
unless defined $disposition 0 0 0
39 unless defined $disposition;
40  
41 open my $fh, '<', $file
42 0 ▶ or do { $t->{t}{plug_send_file_error} = $!; return; };
Branch: 1 branch
BranchTrueFalseTotal
open my $fh, "<", $file or do { $t->{"t"}{"plug_send_file_error"} = $!; return } 0 0 0
43  
44 0 ▶ $type = MIME::Types->new->mimeTypeOf($file)
Branch: 1 branch
BranchTrueFalseTotal
unless defined $type 0 0 0
45 unless defined $type;
46  
47 0 ▶ $type = 'application/octet-stream'
Branch: 1 branch
BranchTrueFalseTotal
unless defined $type 0 0 0
48 unless defined $type;
49  
50 0 print "Content-Disposition: $disposition; filename=$filename\n";
51  
52 0 print "Content-Type: $type\n\n";
53 0 print for <$fh>;
54 0 exit;
55 }
56  
57 1 1;
58 __END__
« ZofCMS/Plugin/FormMailer.pm ↑ Summary ZofCMS/Plugin/Barcode.pm »