AnyEvent/FTP/Server/Role/Help.pm

filter: Statementstmt 97.4% 38 / 39 Branchbran 87.5% 7 / 8 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 7 / 7 Podpod 0.0% 0 / 2 totaltotal 92.8% 52 / 56 SCAR 16.1
CC
5
Cov
96%
cmd_help
5.0
BEGIN
1.0
BEGIN
1.0
CRAP 5.0
« AnyEvent/FTP/Server/Role/TransferPrep.pm ↑ Summary AnyEvent/FTP/Server.pm »
1 package AnyEvent::FTP::Server::Role::Help;
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::Role;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 # ABSTRACT: Help role for FTP server
9 25 our $VERSION = '0.19'; # VERSION
10  
11  
12 25 my %cmds;
13  
14 6 ▶sub help_help { 'HELP [<sp> command]' }
Subroutine help_help: called CC=1 SCAR=0.0
Pod undocumented
15  
16 sub cmd_help
17 {
18 108 ▶ my($self, $con, $req) = @_;
Subroutine cmd_help: called CC=5 SCAR=16.1
Pod undocumented
19  
20 108 my $topic = $req->args;
21 108 $topic =~ s/^\s+//;
22 108 $topic =~ s/\s+$//;
23 108 $topic = lc $topic;
24  
25 108 ▶ if($topic eq '')
Branch: 2 branches
BranchTrueFalseTotal
if ($topic eq '') { } 6 102 108
elsif ($self->can("cmd_$topic")) { } 99 3 102
26 {
27 6 my $class = ref $self;
28 6 ▶ unless(defined $cmds{$class})
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $cmds{$class}) 4 2 6
29 {
30 25 ▶ no strict 'refs';
Subroutine BEGIN: called CC=1 SCAR=0.0
31 $cmds{$class} = [
32 4 sort map { my $x = $_; $x =~ s/^cmd_//; uc $x } grep /^cmd_/, keys %{$class . '::'}
33 ];
34 }
35  
36 $con->send_response(214, [
37 'The following commands are recognized:',
38 6 join(' ', @{ $cmds{$class} }),
39 'Direct comments to devnull@bogus',
40 ]);
41 }
42 elsif($self->can("cmd_$topic"))
43 {
44 99 my $method = "help_$topic";
45 99 ▶ if($self->can("help_$topic"))
Branch: 1 branch
BranchTrueFalseTotal
if ($self->can("help_$topic")) { } 99 0 99
46 {
47 99 $con->send_response(214 => 'Syntax: ' . $self->$method)
48 }
49 else
50 {
51 0 $con->send_response(502 => uc($topic) . " is a command without help");
52 }
53 }
54 else
55 {
56 3 $con->send_response(502 => 'Unknown command');
57 }
58  
59 108 $self->done;
60 }
61  
62 25 1;
63  
64 __END__
« AnyEvent/FTP/Server/Role/TransferPrep.pm ↑ Summary AnyEvent/FTP/Server.pm »