File Coverage

blib/lib/AnyEvent/FTP/Client/Role/ListTransfer.pm
Criterion Covered Total %
statement 29 33 87.8
branch 1 4 25.0
condition n/a
subroutine 9 10 90.0
pod 0 3 0.0
total 39 50 78.0


line stmt bran cond sub pod time code
1             package AnyEvent::FTP::Client::Role::ListTransfer;
2              
3 24     24   14584 use strict;
  24         57  
  24         996  
4 24     24   123 use warnings;
  24         162  
  24         1344  
5 24     24   528 use 5.010;
  24         91  
6 24     24   150 use Moo::Role;
  24         76  
  24         197  
7              
8             # ABSTRACT: Fetch transfer interface for AnyEvent::FTP objects
9             our $VERSION = '0.20'; # VERSION
10              
11             sub xfer
12             {
13 24     24 0 79 my($self, $fh, $local) = @_;
14              
15 24         209 my $handle = $self->handle($fh);
16              
17             $handle->on_read(sub {
18             $handle->push_read(line => sub {
19 58         3177 my($handle, $line) = @_;
20 58         268 $line =~ s/\015?\012//g;
21 58         111 push @{ $local }, $line;
  58         193  
22 58     58   3645 });
23 24         190 });
24             }
25              
26             sub convert_local
27             {
28 24     24 0 150 my($self, $local) = @_;
29 24         155 return $local;
30             }
31              
32             sub push_command
33             {
34 24     24 0 62 my $self = shift;
35             my $cv = $self->{client}->push_command(
36 24         171 @_,
37             );
38              
39             $cv->cb(sub {
40 0     0   0 eval { $cv->recv };
  0         0  
41 0         0 my $err = $@;
42 0 0       0 $self->{cv}->croak($err) if $err;
43 24         252 });
44              
45             $self->on_eof(sub {
46             $cv->cb(sub {
47 24         491 my $res = eval { $cv->recv };
  24         162  
48 24 50       316 $self->{cv}->send($res) unless $@;
49 24     24   342 });
50 24         523 });
51             }
52              
53             1;
54              
55             __END__