| 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
Condition66%2/3
ref $param eq "ARRAY" and not ref $param->[0]
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]
| |||||||||||||||||||||||||||||
| 15 | 1 | my @upload = @$param; | |||||||||||||||||||||||||||
| 16 | 1 | ▶ | croak("need a filename for now (TODO)") unless $upload[0]; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 17 | 1 | ▶ | open my $fh, $upload[0] or croak("Can't open file $upload[0]: $!"); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 18 | 1 | ▶ | return [Froody::Upload->new | ||||||||||||||||||||||||||
|
Condition33%1/3
$upload[1] || $upload[0]
MC/DC0%0/2
$upload[1] || $upload[0]
$upload[1]
$upload[0]
Truth table33%1/3
A || B
A= $upload[1]B= $upload[0]
| |||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||
| 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 | ||||||||||||||||||||||||||||