AnyEvent/FTP/Client/Role/ResponseBuffer.pm

filter: Statementstmt 97.4% 38 / 39 Branchbran 83.3% 5 / 6 Conditioncond 66.6% 2 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 100% 8 / 8 Podpod 0.0% 0 / 3 totaltotal 86.8% 53 / 61 SCAR 19.5
CC
7
Cov
94%
process_message_line
7.1
BEGIN
1.0
BEGIN
1.0
CRAP 7.0
« AnyEvent/FTP/Server/Role/Auth.pm ↑ Summary AnyEvent/FTP/Server/Context.pm »
1 package AnyEvent::FTP::Client::Role::ResponseBuffer;
2  
3 26 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 26 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 26 ▶use 5.010;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 26 ▶use Moo::Role;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 26 ▶use AnyEvent::FTP::Client::Response;
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 # ABSTRACT: Response buffer role for asynchronous ftp client
10 26 our $VERSION = '0.19'; # VERSION
11  
12  
13 sub on_next_response
14 {
15 822 ▶ my($self, $cb) = @_;
Subroutine on_next_response: called CC=1 SCAR=0.0
Pod undocumented
16 822 push @{ $self->{response_buffer}->{once} }, $cb;
17 }
18  
19 sub on_each_response
20 {
21 1 ▶ my($self, $cb) = @_;
Subroutine on_each_response: called CC=1 SCAR=0.0
Pod undocumented
22 1 push @{ $self->{response_buffer}->{each} }, $cb;
23 }
24  
25 sub process_message_line
26 {
27 845 ▶ my($self, $line) = @_;
Subroutine process_message_line: called CC=7 SCAR=19.6
Pod undocumented
28  
29 845 $line =~ s/\015?\012//g;
30  
31 845 ▶ if($line =~ s/^(\d\d\d)([- ])//)
Branch: 2 branches
BranchTrueFalseTotal
if ($line =~ s/^(\d\d\d)([- ])//) { } 841 4 845
elsif (@{$self->{'response_buffer'}{'message'};} > 0) { } 4 0 4
32 {
33 841 ▶ $self->{response_buffer}->{code} //= $1;
Condition66%2/3
$self->{"response_buffer"}{"code"} //= $1
l!l&&r!l&&!r
198220
MC/DC0%0/2
$self->{"response_buffer"}{"code"} //= $1
$self->{"response_buffer"}{"code"} $1
Truth table66%2/3
A //= B
A= $self->{"response_buffer"}{"code"}B= $1
ABresult
1X1
011
000
34 841 push @{ $self->{response_buffer}->{message} }, $line;
35 841 ▶ if($2 eq ' ')
Branch: 1 branch
BranchTrueFalseTotal
if ($2 eq " ") 822 19 841
36 {
37 my $response = AnyEvent::FTP::Client::Response->new(
38 $self->{response_buffer}->{code},
39 $self->{response_buffer}->{message},
40 822 );
41 822 delete $self->{response_buffer}->{$_} for qw( code message );
42 822 my $once = delete $self->{response_buffer}->{once};
43 $_->($response)
44 822 for @{ $self->{response_buffer}->{each} }, @{ $once };
45 }
46 }
47 4 elsif(@{ $self->{response_buffer}->{message} } > 0)
48 {
49 4 push @{ $self->{response_buffer}->{message} }, $line;
50 }
51 else
52 {
53 0 warn "bad message: $line";
54 }
55 }
56  
57 26 1;
58  
59 __END__
« AnyEvent/FTP/Server/Role/Auth.pm ↑ Summary AnyEvent/FTP/Server/Context.pm »