File Coverage

blib/lib/AnyEvent/FTP/Server/Role/Type.pm
Criterion Covered Total %
statement 21 21 100.0
branch 2 2 100.0
condition 3 3 100.0
subroutine 6 6 100.0
pod 0 2 0.0
total 32 34 94.1


line stmt bran cond sub pod time code
1             package AnyEvent::FTP::Server::Role::Type;
2              
3 24     24   263842 use strict;
  24         49  
  24         632  
4 24     24   97 use warnings;
  24         42  
  24         435  
5 24     24   340 use 5.010;
  24         67  
6 24     24   519 use Moo::Role;
  24         20125  
  24         114  
7              
8             # ABSTRACT: Type role for FTP server
9             our $VERSION = '0.19'; # VERSION
10              
11              
12             has type => (
13             is => 'rw',
14             default => sub { 'A' },
15             );
16              
17              
18 3     3 0 10 sub help_type { 'TYPE type-code (A, I)' }
19              
20             sub cmd_type
21             {
22 30     30 0 72 my($self, $con, $req) = @_;
23              
24 30         79 my $type = uc $req->args;
25 30         92 $type =~ s/^\s+//;
26 30         61 $type =~ s/\s+$//;
27              
28 30 100 100     145 if($type eq 'A' || $type eq 'I')
29             {
30 28         93 $self->type($type);
31 28         114 $con->send_response(200 => "Type set to $type");
32             }
33             else
34             {
35 2         7 $con->send_response(500 => "Type not understood");
36             }
37              
38 30         94 $self->done;
39             }
40              
41             # TODO: STRU MODE
42              
43             1;
44              
45             __END__