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   10348 use strict;
  24         57  
  24         559  
4 24     24   93 use warnings;
  24         41  
  24         459  
5 24     24   329 use 5.010;
  24         65  
6 24     24   97 use Moo::Role;
  24         39  
  24         164  
7              
8             # ABSTRACT: Fetch transfer interface for AnyEvent::FTP objects
9             our $VERSION = '0.19'; # VERSION
10              
11             sub xfer
12             {
13 24     24 0 71 my($self, $fh, $local) = @_;
14              
15 24         149 my $handle = $self->handle($fh);
16              
17             $handle->on_read(sub {
18             $handle->push_read(line => sub {
19 58         2111 my($handle, $line) = @_;
20 58         126 $line =~ s/\015?\012//g;
21 58         107 push @{ $local }, $line;
  58         147  
22 58     58   2532 });
23 24         142 });
24             }
25              
26             sub convert_local
27             {
28 24     24 0 58 my($self, $local) = @_;
29 24         48 return $local;
30             }
31              
32             sub push_command
33             {
34 24     24 0 48 my $self = shift;
35             my $cv = $self->{client}->push_command(
36 24         91 @_,
37             );
38              
39             $cv->cb(sub {
40 14     14   161 eval { $cv->recv };
  14         72  
41 14         52 my $err = $@;
42 14 50       40 $self->{cv}->croak($err) if $err;
43 24         160 });
44              
45             $self->on_eof(sub {
46             $cv->cb(sub {
47 24         248 my $res = eval { $cv->recv };
  24         136  
48 24 50       184 $self->{cv}->send($res) unless $@;
49 24     24   226 });
50 24         313 });
51             }
52              
53             1;
54              
55             __END__