AnyEvent/FTP/Client/Transfer/Active.pm

filter: Statementstmt 100% 54 / 54 Branchbran 75.0% 3 / 4 Conditioncond 33.3% 1 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 100% 14 / 14 Podpod 0.0% 0 / 1 totaltotal 92.3% 72 / 78 SCAR 13.9
CC
4
Cov
95%
__ANON__
2.1
__ANON__
2.0
__ANON__
2.0
CRAP 4.0
« AnyEvent/FTP/Client/Response.pm ↑ Summary AnyEvent/FTP/Role/Event.pm »
1 package AnyEvent::FTP::Client::Transfer::Active;
2  
3 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 2 ▶use Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 2 ▶use 5.010;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 2 ▶use AnyEvent;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 2 ▶use AnyEvent::Socket qw( tcp_server );
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 2 extends 'AnyEvent::FTP::Client::Transfer';
11  
12 # ABSTRACT: Active transfer class for asynchronous ftp client
13 2 our $VERSION = '0.19'; # VERSION
14  
15 sub BUILD
16 {
17 29 ▶ my($self) = @_;
Subroutine BUILD: called CC=1 SCAR=0.0
Pod undocumented
18  
19 29 my $local = $self->convert_local($self->local);
20  
21 29 my $count = 0;
22 29 my $guard;
23 $guard = tcp_server $self->client->{my_ip}, undef, sub {
24 29 ▶ my($fh, $host, $port) = @_;
Subroutine __ANON__: called CC=2 SCAR=7.0
25 # TODO double check the host/port combo here.
26  
27 29 ▶ return close $fh if ++$count > 1;
Branch: 1 branch
BranchTrueFalseTotal
if ++$count > 1 0 29 29
28  
29 29 undef $guard; # close to additional connections.
30  
31 29 $self->xfer($fh,$local);
32 }, sub {
33  
34 29 ▶ my($fh, $host, $port) = @_;
Subroutine __ANON__: called CC=1 SCAR=0.0
35 29 my $ip_and_port = join(',', split(/\./, $self->client->{my_ip}), $port >> 8, $port & 0xff);
36  
37 29 my $w;
38 $w = AnyEvent->timer(after => 0, cb => sub {
39 29 ▶ $self->push_command(
Subroutine __ANON__: called CC=2 SCAR=6.9
Branch: 1 branch
BranchTrueFalseTotal
$self->restart > 0 ? : 2 27 29
40 [ PORT => $ip_and_port ],
41 ($self->restart > 0 ? ([ REST => $self->restart ]) : ()),
42 $self->command,
43 );
44 29 undef $w;
45 29 });
46 29 };
47  
48 $self->cv->cb(sub {
49 20 ▶ my $res = eval { shift->recv } // $@;
Subroutine __ANON__: called CC=2 SCAR=7.6
Condition33%1/3
eval { do { (shift())->recv } } // $@
l!l&&r!l&&!r
2000
MC/DC0%0/2
eval { do { (shift())->recv } } // $@
eval { do { (shift())->recv } } $@
Truth table33%1/3
A // B
A= eval { do { (shift())->recv } }B= $@
ABresult
1X1
011
000
50 20 $self->emit('close' => $res);
51 29 });
52  
53 }
54  
55 package AnyEvent::FTP::Client::Transfer::Active::Fetch;
56  
57 2 ▶use Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
58 2 extends 'AnyEvent::FTP::Client::Transfer::Active';
59  
60 2 with 'AnyEvent::FTP::Client::Role::FetchTransfer';
61  
62 package AnyEvent::FTP::Client::Transfer::Active::Store;
63  
64 2 ▶use Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
65 2 extends 'AnyEvent::FTP::Client::Transfer::Active';
66  
67 2 with 'AnyEvent::FTP::Client::Role::StoreTransfer';
68  
69 package AnyEvent::FTP::Client::Transfer::Active::List;
70  
71 2 ▶use Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
72 2 extends 'AnyEvent::FTP::Client::Transfer::Active';
73  
74 2 with 'AnyEvent::FTP::Client::Role::ListTransfer';
75  
76 2 1;
77  
78 __END__
« AnyEvent/FTP/Client/Response.pm ↑ Summary AnyEvent/FTP/Role/Event.pm »