| line | stmt | bran | cond | sub | pod | time | code | 
| 1 |  |  |  |  |  |  | package NcFTPd::Log::Parse; | 
| 2 |  |  |  |  |  |  |  | 
| 3 | 1 |  |  | 1 |  | 26081 | use strict; | 
|  | 1 |  |  |  |  | 3 |  | 
|  | 1 |  |  |  |  | 42 |  | 
| 4 | 1 |  |  | 1 |  | 6 | use warnings; | 
|  | 1 |  |  |  |  | 2 |  | 
|  | 1 |  |  |  |  | 32 |  | 
| 5 | 1 |  |  | 1 |  | 6 | use vars qw{$VERSION}; | 
|  | 1 |  |  |  |  | 1 |  | 
|  | 1 |  |  |  |  | 41 |  | 
| 6 |  |  |  |  |  |  |  | 
| 7 | 1 |  |  | 1 |  | 6 | use File::Basename; | 
|  | 1 |  |  |  |  | 1 |  | 
|  | 1 |  |  |  |  | 53 |  | 
| 8 | 1 |  |  | 1 |  | 5 | use Carp; | 
|  | 1 |  |  |  |  | 2 |  | 
|  | 1 |  |  |  |  | 53 |  | 
| 9 | 1 |  |  | 1 |  | 643 | use NcFTPd::Log::Parse::Misc; | 
|  | 1 |  |  |  |  | 3 |  | 
|  | 1 |  |  |  |  | 26 |  | 
| 10 | 1 |  |  | 1 |  | 626 | use NcFTPd::Log::Parse::Session; | 
|  | 1 |  |  |  |  | 3 |  | 
|  | 1 |  |  |  |  | 27 |  | 
| 11 | 1 |  |  | 1 |  | 636 | use NcFTPd::Log::Parse::Xfer; | 
|  | 1 |  |  |  |  | 3 |  | 
|  | 1 |  |  |  |  | 234 |  | 
| 12 |  |  |  |  |  |  |  | 
| 13 |  |  |  |  |  |  | $VERSION = '0.001'; | 
| 14 |  |  |  |  |  |  |  | 
| 15 |  |  |  |  |  |  | my %PARSERS = ( | 
| 16 |  |  |  |  |  |  | xfer => 'NcFTPd::Log::Parse::Xfer', | 
| 17 |  |  |  |  |  |  | sess => 'NcFTPd::Log::Parse::Session', | 
| 18 |  |  |  |  |  |  | misc => 'NcFTPd::Log::Parse::Misc' | 
| 19 |  |  |  |  |  |  | ); | 
| 20 |  |  |  |  |  |  |  | 
| 21 |  |  |  |  |  |  | $PARSERS{session} = $PARSERS{sess}; | 
| 22 |  |  |  |  |  |  |  | 
| 23 |  |  |  |  |  |  | sub new | 
| 24 |  |  |  |  |  |  | { | 
| 25 | 9 |  |  | 9 | 1 | 3696 | my $class = shift; | 
| 26 | 9 | 50 |  |  |  | 24 | croak 'usage: NcFTP::Log::Parse->new($file [, %options ] | %options)' unless @_; | 
| 27 |  |  |  |  |  |  |  | 
| 28 | 9 | 100 |  |  |  | 25 | my $file    = shift if @_ % 2; | 
| 29 | 9 |  |  |  |  | 20 | my %options = @_; | 
| 30 | 9 |  |  |  |  | 8 | my $parser; | 
| 31 |  |  |  |  |  |  |  | 
| 32 | 9 | 100 |  |  |  | 18 | if(defined $file) { | 
| 33 | 5 |  |  |  |  | 160 | my $basename      = basename($file); | 
| 34 | 5 |  |  |  |  | 16 | my $known_parsers = join '|', keys %PARSERS; | 
| 35 | 5 | 100 |  |  |  | 54 | if($basename =~ /^($known_parsers)/i) { | 
| 36 | 4 |  |  |  |  | 11 | $parser = $PARSERS{lc $1}; | 
| 37 |  |  |  |  |  |  | } | 
| 38 |  |  |  |  |  |  | } | 
| 39 |  |  |  |  |  |  | else { | 
| 40 | 4 |  |  |  |  | 14 | for my $format (keys %PARSERS) { | 
| 41 | 12 | 100 |  |  |  | 29 | if(defined $options{$format}) { | 
| 42 | 3 |  |  |  |  | 5 | $file   = $options{$format}; | 
| 43 | 3 |  |  |  |  | 7 | $parser = $PARSERS{$format}; | 
| 44 | 3 |  |  |  |  | 6 | last; | 
| 45 |  |  |  |  |  |  | } | 
| 46 |  |  |  |  |  |  | } | 
| 47 |  |  |  |  |  |  | } | 
| 48 |  |  |  |  |  |  |  | 
| 49 | 9 | 100 |  |  |  | 381 | croak 'Cannot determine what parser to use, try setting it explicitly' unless $parser; | 
| 50 |  |  |  |  |  |  |  | 
| 51 | 7 |  |  |  |  | 59 | $parser->new($file, %options); | 
| 52 |  |  |  |  |  |  | } | 
| 53 |  |  |  |  |  |  |  | 
| 54 |  |  |  |  |  |  | 1; | 
| 55 |  |  |  |  |  |  |  | 
| 56 |  |  |  |  |  |  | __END__ |