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   240650 use strict;
  24         70  
  24         852  
4 24     24   142 use warnings;
  24         63  
  24         657  
5 24     24   511 use 5.010;
  24         94  
6 24     24   626 use Moo::Role;
  24         17968  
  24         168  
7              
8             # ABSTRACT: Type role for FTP server
9             our $VERSION = '0.17'; # VERSION
10              
11              
12             has type => (
13             is => 'rw',
14             default => sub { 'A' },
15             );
16              
17              
18 3     3 0 14 sub help_type { 'TYPE type-code (A, I)' }
19              
20             sub cmd_type
21             {
22 30     30 0 153 my($self, $con, $req) = @_;
23              
24 30         87 my $type = uc $req->args;
25 30         122 $type =~ s/^\s+//;
26 30         77 $type =~ s/\s+$//;
27              
28 30 100 100     186 if($type eq 'A' || $type eq 'I')
29             {
30 28         117 $self->type($type);
31 28         157 $con->send_response(200 => "Type set to $type");
32             }
33             else
34             {
35 2         10 $con->send_response(500 => "Type not understood");
36             }
37              
38 30         167 $self->done;
39             }
40              
41             # TODO: STRU MODE
42              
43             1;
44              
45             __END__