File Coverage

blib/lib/AnyEvent/FTP/Client/Role/ListTransfer.pm
Criterion Covered Total %
statement 33 33 100.0
branch 2 4 50.0
condition n/a
subroutine 10 10 100.0
pod 0 3 0.0
total 45 50 90.0


line stmt bran cond sub pod time code
1             package AnyEvent::FTP::Client::Role::ListTransfer;
2              
3 24     24   13702 use strict;
  24         83  
  24         842  
4 24     24   138 use warnings;
  24         55  
  24         612  
5 24     24   434 use 5.010;
  24         91  
6 24     24   162 use Moo::Role;
  24         76  
  24         184  
7              
8             # ABSTRACT: Fetch transfer interface for AnyEvent::FTP objects
9             our $VERSION = '0.18'; # VERSION
10              
11             sub xfer
12             {
13 24     24 0 86 my($self, $fh, $local) = @_;
14              
15 24         168 my $handle = $self->handle($fh);
16              
17             $handle->on_read(sub {
18             $handle->push_read(line => sub {
19 58         3048 my($handle, $line) = @_;
20 58         164 $line =~ s/\015?\012//g;
21 58         125 push @{ $local }, $line;
  58         187  
22 58     58   3833 });
23 24         193 });
24             }
25              
26             sub convert_local
27             {
28 24     24 0 88 my($self, $local) = @_;
29 24         77 return $local;
30             }
31              
32             sub push_command
33             {
34 24     24 0 75 my $self = shift;
35             my $cv = $self->{client}->push_command(
36 24         149 @_,
37             );
38              
39             $cv->cb(sub {
40 12     12   196 eval { $cv->recv };
  12         65  
41 12         69 my $err = $@;
42 12 50       56 $self->{cv}->croak($err) if $err;
43 24         232 });
44              
45             $self->on_eof(sub {
46             $cv->cb(sub {
47 24         392 my $res = eval { $cv->recv };
  24         264  
48 24 50       266 $self->{cv}->send($res) unless $@;
49 24     24   369 });
50 24         459 });
51             }
52              
53             1;
54              
55             __END__