File Coverage

blib/lib/Logfile/EPrints/Mapping/EPrints.pm
Criterion Covered Total %
statement 22 22 100.0
branch 11 12 91.6
condition 3 3 100.0
subroutine 5 5 100.0
pod 0 2 0.0
total 41 44 93.1


line stmt bran cond sub pod time code
1             package Logfile::EPrints::Mapping::EPrints;
2              
3 6     6   29 use strict;
  6         14  
  6         191  
4 6     6   29 use warnings;
  6         12  
  6         2206  
5              
6             sub new {
7 4     4 0 17 my ($class,%self) = @_;
8              
9 4 50       15 Carp::croak(__PACKAGE__." requires identifier argument") unless exists $self{identifier};
10              
11 4         23 bless \%self, $class;
12             }
13              
14             sub hit {
15 1146     1146 0 12231 my ($self,$hit) = @_;
16 1146 100 100     4351 if( 'GET' eq $hit->method && 200 == $hit->code ) {
17 725         2740 my $path = URI->new($hit->page,'http')->path;
18             # Full text
19 725 100       59308 if( $path =~ /^(?:\/archive)?\/(\d+)\/\d/ ) {
    100          
    100          
    100          
20 64         148 $hit->{identifier} = $self->_identifier($1);
21 64         476 $self->{handler}->fulltext($hit);
22             } elsif( $path =~ /^(?:\/archive)?\/(\d+)\/?$/ ) {
23 154         314 $hit->{identifier} = $self->_identifier($1);
24 154         685 $self->{handler}->abstract($hit);
25             } elsif( $path =~ /^\/view\/(\w+)\// ) {
26 197         475 $hit->{section} = $1;
27 197         1055 $self->{handler}->browse($hit);
28             } elsif( $path =~ /^\/perl\/search/ ) {
29 10         52 $self->{handler}->search($hit);
30             } else {
31             #warn "Unknown path = ", $uri->path, "\n";
32             }
33             }
34             }
35              
36             sub _identifier {
37 218     218   388 my ($self,$no) = @_;
38 218         778 return $self->{'identifier'}.($no+0);
39             }
40              
41             # Autoload methods go after =cut, and are processed by the autosplit program.
42              
43             1;
44             __END__