blib/lib/Froody/Argument/Multipart.pm

filter: Statementstmt 100% 27 / 27 Branchbran 62.5% 5 / 8 Conditioncond 50.0% 3 / 6 MC/DCmcdc 25.0% 1 / 4 Subroutinesub 100% 6 / 6 Podpod 100% 2 / 2 totaltotal 83.0% 44 / 53 CC 8 SCAR 17.5
CC
8
Cov
85%
process
8.7
BEGIN
1.0
BEGIN
1.0
CRAP 5.7
« blib/lib/Froody/Invoker/Implementation.pm ↑ Summary blib/lib/Froody/Walker/XML.pm »
1 package Froody::Argument::Multipart;
2 18 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 18 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 18 ▶use base 'Froody::Argument';
Subroutine BEGIN: called CC=1 SCAR=0.0
5 18 ▶use Carp qw( croak );
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 17 ▶sub type { 'multipart' , 'file' }
Subroutine type: called CC=1 SCAR=0.0
Pod documented
8  
9 2 ▶sub process {
Subroutine process: called CC=8 SCAR=21.6
Pod documented
10 2 my ($class, $param, $check) = @_;
11  
12 # Special case - if we're passed ['filename'] as the arg, treat
13 # it as a file upload. Mostly for testing purposes.
14 2 ▶ if (ref( $param ) eq 'ARRAY' and !ref($param->[0]) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $param eq "ARRAY" and not ref $param->[0]) 1 1 2
Condition66%2/3
ref $param eq "ARRAY" and not ref $param->[0]
!ll&&!rl&&r
101
MC/DC50%1/2
ref $param eq "ARRAY" and not ref $param->[0]
ref $param eq "ARRAY" not ref $param->[0]
Truth table66%2/3
A and not(B)
A= ref $param eq "ARRAY"B= not ref $param->[0]
ABresult
0X0
100
111
15 1 my @upload = @$param;
16 1 ▶ croak("need a filename for now (TODO)") unless $upload[0];
Branch: 1 branch
BranchTrueFalseTotal
unless $upload[0] 0 1 1
17 1 ▶ open my $fh, $upload[0] or croak("Can't open file $upload[0]: $!");
Branch: 1 branch
BranchTrueFalseTotal
open my $fh, $upload[0] or croak("Can't open file $upload[0]: $!") 1 0 1
18 1 ▶ return [Froody::Upload->new
Condition33%1/3
$upload[1] || $upload[0]
l!l&&r!l&&!r
010
MC/DC0%0/2
$upload[1] || $upload[0]
$upload[1] $upload[0]
Truth table33%1/3
A || B
A= $upload[1]B= $upload[0]
ABresult
1X1
011
000
19 ->fh($fh)
20 ->filename($upload[0])
21 ->client_filename($upload[1] || $upload[0])];
22  
23 }
24  
25 1 ▶ if (ref($param) ne 'ARRAY') {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $param ne "ARRAY") 1 0 1
26 1 $param = [$param];
27 }
28  
29 1 my $i = 0;
30 1 for my $val (@$param) {
31 1 $check->( ref $val eq 'Froody::Upload',
32 "Element $i is not an upload record");
33 1 ++$i;
34 }
35  
36 1 return $param;
37 }
38  
39 18 1;
40  
41 =head1 NAME
42  
43 Froody::Argument::Multipart - Froody argument type handler for multipart attachments
44  
45 =head1 AUTHORS
46  
47 Copyright Fotango 2006. All rights reserved.
48  
49 Please see the main L<Froody> documentation for details of who has worked
50 on this project.
51  
52 This module is free software; you can redistribute it and/or modify it under
53 the same terms as Perl itself.
54  
55 =cut
« blib/lib/Froody/Invoker/Implementation.pm ↑ Summary blib/lib/Froody/Walker/XML.pm »