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   246918 use strict;
  24         71  
  24         835  
4 24     24   136 use warnings;
  24         56  
  24         596  
5 24     24   441 use 5.010;
  24         93  
6 24     24   594 use Moo::Role;
  24         17557  
  24         149  
7              
8             # ABSTRACT: Type role for FTP server
9             our $VERSION = '0.18'; # VERSION
10              
11              
12             has type => (
13             is => 'rw',
14             default => sub { 'A' },
15             );
16              
17              
18 3     3 0 11 sub help_type { 'TYPE type-code (A, I)' }
19              
20             sub cmd_type
21             {
22 30     30 0 84 my($self, $con, $req) = @_;
23              
24 30         80 my $type = uc $req->args;
25 30         129 $type =~ s/^\s+//;
26 30         93 $type =~ s/\s+$//;
27              
28 30 100 100     275 if($type eq 'A' || $type eq 'I')
29             {
30 28         121 $self->type($type);
31 28         141 $con->send_response(200 => "Type set to $type");
32             }
33             else
34             {
35 2         12 $con->send_response(500 => "Type not understood");
36             }
37              
38 30         149 $self->done;
39             }
40              
41             # TODO: STRU MODE
42              
43             1;
44              
45             __END__