| 1 | package POE::Component::Net::FTP; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | 2 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | 2 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | 2 | our $VERSION = '0.002'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | 2 | ▶ | use Carp; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | 2 | ▶ | use POE; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | 2 | ▶ | use Net::FTP; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | 2 | ▶ | use base 'POE::Component::NonBlockingWrapper::Base'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | 2 | my %True_False_Commands = map { $_ => 1 } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | qw( new login authorize ascii binary rename delete | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | cwd cdup restart rmdir mkdir alloc | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | nlst list retr stor stou appe port | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | pasv_xfer pasv_xfer_unique pasv_wait abort quit | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | 2 | my %Undef_On_Fail_Commands = map { $_ => 1 } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | qw( site pwd get put put_unique append unique_name | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | mdtm size pasv quot | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | 2 | my %In_List_Context_Commands = map { $_ => 1 } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | qw( ls dir feature); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | # feature will return empty list if feature is not supported | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | 2 | my %In_Scalar_Context_No_Fail_Commands = map { $_ => 1 } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | qw(supported hash); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | 1 | ▶ | sub _methods_define { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_methods_define: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | 1 | return ( process => '_wheel_entry', ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | 0 | ▶ | sub process { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
process: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | 0 | $poe_kernel->post( shift->{session_id} => process => @_ ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | 0 | ▶ | sub _check_args { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_check_args: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | 0 | my ( $self, $in_ref ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | exists $in_ref->{commands} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | 0 | ▶ | or carp "Missing `commands` argument" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/5
exists $in_ref->{'commands'} || carp('Missing `commands` argument') && (return)
carp("Missing `commands` argument") and return
MC/DC0%0/2
exists $in_ref->{'commands'} || carp('Missing `commands` argument') && (return)
exists $in_ref->{'commands'}
carp("Missing `commands` argument")
Truth table0%0/3
A || B
A= exists $in_ref->{'commands'}B= carp("Missing `commands` argument")
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | and return; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | 0 | return 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | 0 | ▶ | sub _prepare_wheel { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_prepare_wheel: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | $self->{stop_on_error} = 1 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | 0 | ▶ | unless exists $self->{stop_on_error}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | 0 | ▶ | sub _process_request { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_process_request: not called CC=18 SCAR=58.3
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | 0 | my ( $self, $in_ref ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | 0 | my @responses; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | 0 | my ( $is_error, $last_error ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | 0 | for ( @{ $in_ref->{commands} } ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | last | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | 0 | ▶ | if $self->{stop_on_error} and $is_error; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$self->{"stop_on_error"} and $is_error
MC/DC0%0/2
$self->{"stop_on_error"} and $is_error
$self->{"stop_on_error"}
$is_error
Truth table0%0/3
A and B
A= $self->{"stop_on_error"}B= $is_error
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | 0 | my ( $command, $options_ref ) = %$_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | 0 | $command = lc $command; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | 0 | eval { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | 0 | ▶ | if ( $command eq 'new' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 5 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | 0 | ▶ | $self->{obj} = Net::FTP->new( @$options_ref ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/11
($self->{'obj'} = 'Net::FTP'->new(@$options_ref)) || push(@responses, [$@]) && ($is_error = $command) && ($last_error = $@) && (next)
push @responses, [$@] and $is_error = $command and $last_error = $@ and next
push @responses, [$@] and $is_error = $command and $last_error = $@
push @responses, [$@] and $is_error = $command
MC/DC0%0/4
($self->{'obj'} = 'Net::FTP'->new(@$options_ref)) || push(@responses, [$@]) && ($is_error = $command) && ($last_error = $@) && (next)
($self->{'obj'} = 'Net::FTP'->new(@$options_ref))
push @responses, [$@]
$is_error = $command
$last_error = $@
Truth table0%0/5
A || B and C and D
A= ($self->{'obj'} = 'Net::FTP'->new(@$options_ref))B= push @responses, [$@]C= $is_error = $commandD= $last_error = $@
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | or push @responses, [ $@ ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | and $is_error = $command | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | and $last_error = $@ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | and next; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | 0 | push @responses, [ 1 ]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | elsif ( exists $True_False_Commands{ $command } ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | 0 | ▶ | if ( my $res = $self->{obj}->$command( @$options_ref ) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | 0 | push @responses, [ $res ]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | 0 | my $error = $self->{obj}->message; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | 0 | push @responses, [ $error ]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | 0 | $is_error = $command; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | 0 | $last_error = $error; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | elsif ( exists $Undef_On_Fail_Commands{ $command } ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | 0 | ▶ | if ( defined( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | my $res = $self->{obj}->$command( @$options_ref ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | ) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | 0 | push @responses, [ $res ]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | 0 | my $error = $self->{obj}->message; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | 0 | push @responses, [ $error ]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | 0 | $is_error = $command; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | elsif ( exists $In_List_Context_Commands{ $command } ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | push @responses, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | 0 | [ $self->{obj}->$command( @$options_ref ) ]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | elsif ( exists $In_Scalar_Context_No_Fail_Commands{ $command } ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | push @responses, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | 0 | [ scalar $self->{obj}->$command( @$options_ref ) ]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | 0 | croak "Invalid command `$command` was specified"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | 0 | ▶ | if ( $@ ) { carp "Fatal error occured during execution: $@\n"; } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | 0 | ▶ | $in_ref->{is_error} = $is_error | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | if $is_error; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | 0 | ▶ | $in_ref->{last_error} = $last_error | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | if $last_error; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | 0 | $in_ref->{responses} = \@responses; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | 2 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||