FromLog/Engine/Default.pm

filter: Statementstmt 100% 35 / 35 Branchbran 83.3% 5 / 6 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 9 / 9 Podpod 100% 2 / 2 totaltotal 98.0% 51 / 52 CC 4 SCAR 6.9
CC
4
Cov
98%
parse
4.0
__ANON__
1.0
BEGIN
1.0
CRAP 2.0
« FromLog.pm ↑ Summary FromLog/Engine/Base.pm »
1 package HTTP::Request::FromLog::Engine::Default;
2  
3 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 2 ▶use base qw(HTTP::Request::FromLog::Engine::Base);
Subroutine BEGIN: called CC=1 SCAR=0.0
6 2 ▶use Parse::AccessLogEntry;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 2 ▶use HTTP::Headers;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 2 ▶use List::MoreUtils qw(all);
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 1 ▶sub new {
Subroutine new: called CC=1 SCAR=0.0
Pod documented
11 1 my $class = shift;
12 1 my %args = @_;
13  
14 1 $args{parser} = Parse::AccessLogEntry->new();
15  
16 1 return $class->SUPER::new(%args);
17 }
18  
19 2 ▶sub parse {
Subroutine parse: called CC=4 SCAR=13.9
Pod documented
20 2 my $self = shift;
21 2 my $log_record = shift;
22  
23 2 my $record = $self->{parser}->parse($log_record);
24  
25 2 ▶ return undef if all { !defined $_ } values %$record;
Subroutine __ANON__: called CC=1 SCAR=0.2
Branch: 1 branch
BranchTrueFalseTotal
if &all(sub { not defined $_; } , values %$record) 0 2 2
26  
27 2 my $method = $record->{rtype};
28 2 my $uri = $self->{scheme} . '://' . $self->{host} . $record->{file};
29 2 my $header = HTTP::Headers->new();
30 2 $header->header( host => $self->{host} );
31 2 ▶ $header->header( user_agent => $record->{agent} ) if $record->{agent};
Branch: 1 branch
BranchTrueFalseTotal
if $record->{"agent"} 1 1 2
32 2 ▶ $header->header( referer => $record->{refer} ) if $record->{refer};
Branch: 1 branch
BranchTrueFalseTotal
if $record->{"refer"} 1 1 2
33  
34 2 return ( { method => $method, uri => $uri, header => $header } );
35 }
36  
37 2 1;
38  
39 __END__
« FromLog.pm ↑ Summary FromLog/Engine/Base.pm »