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   14724 use strict;
  24         81  
  24         830  
4 24     24   136 use warnings;
  24         54  
  24         688  
5 24     24   450 use 5.010;
  24         103  
6 24     24   136 use Moo::Role;
  24         68  
  24         182  
7              
8             # ABSTRACT: Fetch transfer interface for AnyEvent::FTP objects
9             our $VERSION = '0.17'; # VERSION
10              
11             sub xfer
12             {
13 24     24 0 84 my($self, $fh, $local) = @_;
14              
15 24         203 my $handle = $self->handle($fh);
16              
17             $handle->on_read(sub {
18             $handle->push_read(line => sub {
19 58         3458 my($handle, $line) = @_;
20 58         224 $line =~ s/\015?\012//g;
21 58         181 push @{ $local }, $line;
  58         250  
22 58     58   4294 });
23 24         199 });
24             }
25              
26             sub convert_local
27             {
28 24     24 0 83 my($self, $local) = @_;
29 24         87 return $local;
30             }
31              
32             sub push_command
33             {
34 24     24 0 73 my $self = shift;
35             my $cv = $self->{client}->push_command(
36 24         153 @_,
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         294 });
44              
45             $self->on_eof(sub {
46             $cv->cb(sub {
47 24         634 my $res = eval { $cv->recv };
  24         353  
48 24 50       346 $self->{cv}->send($res) unless $@;
49 24     24   528 });
50 24         460 });
51             }
52              
53             1;
54              
55             __END__