AnyEvent/FTP/Server/Connection.pm

filter: Statementstmt 97.3% 36 / 37 Branchbran 50.0% 1 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 9 / 9 Podpod 100% 3 / 3 totaltotal 96.0% 49 / 51 SCAR 6.9
CC
2
Cov
95%
process_request
2.0
BEGIN
1.0
BEGIN
1.0
CRAP 2.0
« AnyEvent/FTP/Client/Transfer.pm ↑ Summary AnyEvent/FTP/Client/Site/Proftpd.pm »
1 package AnyEvent::FTP::Server::Connection;
2  
3 25 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 25 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 25 ▶use 5.010;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 25 ▶use Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 25 ▶use AnyEvent::FTP::Request;
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 # ABSTRACT: FTP Server connection class
10 25 our $VERSION = '0.19'; # VERSION
11  
12 25 with 'AnyEvent::FTP::Role::Event';
13  
14 25 __PACKAGE__->define_events(qw( request response close ));
15  
16 25 has context => (
17 is => 'ro',
18 required => 1,
19 );
20  
21 has response_encoder => (
22 is => 'ro',
23 lazy => 1,
24 default => sub {
25 69 ▶ require AnyEvent::FTP::Server::UnambiguousResponseEncoder;
Subroutine __ANON__: called CC=1 SCAR=0.0
26 69 AnyEvent::FTP::Server::UnambiguousResponseEncoder->new;
27 },
28 25 );
29  
30 25 has ip => (
31 is => 'ro',
32 required => 1,
33 );
34  
35 sub process_request
36 {
37 677 ▶ my($self, $line) = @_;
Subroutine process_request: called CC=2 SCAR=7.1
Pod documented
38  
39 677 my $raw = $line;
40  
41 677 $self->emit(request => $raw);
42  
43 677 $line =~ s/\015?\012//g;
44  
45 677 ▶ if($line =~ s/^([A-Z]{1,4})\s?//i)
Branch: 1 branch
BranchTrueFalseTotal
if ($line =~ s/^([A-Z]{1,4})\s?//i) { } 677 0 677
46 {
47 677 $self->context->push_request($self, AnyEvent::FTP::Request->new(uc $1, $line, $raw));
48 }
49 else
50 {
51 0 $self->context->invalid_syntax($self, $raw);
52 }
53  
54 677 $self;
55 }
56  
57 sub send_response
58 {
59 813 ▶ my $self = shift;
Subroutine send_response: called CC=1 SCAR=0.0
Pod documented
60 813 my $raw = $self->response_encoder->encode(@_);
61 813 $self->emit(response => $raw);
62 813 $self;
63 }
64  
65 sub close
66 {
67 80 ▶ my($self) = shift;
Subroutine close: called CC=1 SCAR=0.0
Pod documented
68 80 $self->emit('close');
69 }
70  
71 25 1;
72  
73 __END__
« AnyEvent/FTP/Client/Transfer.pm ↑ Summary AnyEvent/FTP/Client/Site/Proftpd.pm »