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   258382 use strict;
  24         54  
  24         1147  
4 24     24   133 use warnings;
  24         77  
  24         1344  
5 24     24   426 use 5.010;
  24         92  
6 24     24   736 use Moo::Role;
  24         18433  
  24         232  
7              
8             # ABSTRACT: Type role for FTP server
9             our $VERSION = '0.20'; # VERSION
10              
11              
12             has type => (
13             is => 'rw',
14             default => sub { 'A' },
15             );
16              
17              
18 3     3 0 30 sub help_type { 'TYPE type-code (A, I)' }
19              
20             sub cmd_type
21             {
22 30     30 0 103 my($self, $con, $req) = @_;
23              
24 30         102 my $type = uc $req->args;
25 30         131 $type =~ s/^\s+//;
26 30         94 $type =~ s/\s+$//;
27              
28 30 100 100     199 if($type eq 'A' || $type eq 'I')
29             {
30 28         107 $self->type($type);
31 28         199 $con->send_response(200 => "Type set to $type");
32             }
33             else
34             {
35 2         11 $con->send_response(500 => "Type not understood");
36             }
37              
38 30         152 $self->done;
39             }
40              
41             # TODO: STRU MODE
42              
43             1;
44              
45             __END__