blib/lib/Net/FTPServer/XferLog.pm

filter: Statementstmt 100% 53 / 53 Branchbran 87.5% 7 / 8 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 4 / 4 Podpod 0.0% 0 / 1 totaltotal 96.9% 64 / 66 CC 7 SCAR 16.5
CC
7
Cov
98%
parse_line
7.0
BEGIN
1.0
BEGIN
1.0
CRAP 5.2
↑ Summary
1 package Net::FTPServer::XferLog;
2  
3 1 ▶use 5.006;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 1 require Exporter;
8  
9 1 our @ISA = qw(Exporter);
10  
11 # Items to export into callers namespace by default. Note: do not export
12 # names by default without a very good reason. Use EXPORT_OK instead.
13 # Do not simply export all your public functions/methods/constants.
14  
15 # This allows declaration use Net::FTPServer::XferLog ':all';
16 # If you do not need this, moving things directly into @EXPORT or @EXPORT_OK
17 # will save memory.
18 1 our %EXPORT_TAGS = ( 'all' => [ qw(
19
20 ) ] );
21  
22 1 our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } );
23  
24 1 our @EXPORT = qw(
25
26 );
27 1 our $VERSION = '1.5';
28  
29  
30 # Preloaded methods go here.
31  
32 # unused. was going to be strict about the parse. but it is
33 # time-consuming and harder to debug.
34  
35 1 my $day_name = qr/\w{3}/; my $month = qr/\w{3}/;
36 1 my $day = qr/\d{1,2}/; my $time = qr/\d{2}:\d{2}\d{2}/;
37 1 my $year = qr/\d{4}/; my $xfer_time = qr/\d+/;
38 1 my $remote_host = qr/.*/; my $bytes_xfer = qr/\d+/;
39 1 my $filename = qr/(\w|[.])+/;my $xfer_type = qr/([ab])/;
40 1 my $special_act = qr/([CUT_])+/;my $direction = qr/(o|i)/;
41 1 my $access_mode = qr/(a|g|r)/; my $user_name = qr/\w+/;
42 1 my $svc_name = qr/ftp/; my $auth_method = qr/(0|1)/;
43 1 my $auth_userid = qr/([*]|\w+)/;my $status = qr/(c|i)/;
44  
45  
46 1 our @field = qw(day_name month day current_time year transfer_time
47 remote_host file_size filename transfer_type
48 special_action_flag direction access_mode username
49 service_name authentication_method authenticated_user_id
50 completion_status);
51  
52  
53 4 ▶sub parse_line {
Subroutine parse_line: called CC=7 SCAR=19.5
Pod undocumented
54 4 ▶ my $self = shift; my $line = shift or die "must supply xferlog line";
Branch: 1 branch
BranchTrueFalseTotal
my $line = shift() or die "must supply xferlog line" 4 0 4
55  
56 4 my %field;
57  
58 4 my @field = @field;
59  
60 4 my @tmp = split /\s+/, $line;
61 4 ▶ if (scalar @tmp == scalar @field) {
Branch: 1 branch
BranchTrueFalseTotal
if (scalar @tmp == scalar @field) { } 3 1 4
62 3 @field{@field} = @tmp;
63 } else {
64 1 for (@field) {
65 9 ▶ last if $_ eq 'filename';
Branch: 1 branch
BranchTrueFalseTotal
if $_ eq "filename" 1 8 9
66 8 $field{$_} = shift @tmp;
67 }
68
69 1 @field = reverse @field;
70 1 @tmp = reverse @tmp;
71  
72 1 for (@field) {
73 10 ▶ last if $_ eq 'filename';
Branch: 1 branch
BranchTrueFalseTotal
if $_ eq "filename" 1 9 10
74 9 $field{$_} = shift @tmp;
75 }
76  
77 1 @tmp = reverse @tmp ;
78 1 $field{filename} = "@tmp";
79 }
80  
81  
82  
83 # map { print "$_ => $field{$_} \n" } @field;
84 # print "-------------------";
85 4 \%field;
86 }
87
88  
89 1 1;
90 __END__
↑ Summary