EPrints/Mapping/DSpace.pm

filter: Statementstmt 35.0% 7 / 20 Branchbran 0.0% 0 / 8 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 40.0% 2 / 5 Podpod 0.0% 0 / 2 totaltotal 25.7% 9 / 35 CC 5 SCAR 23.7
CC
5
Cov
25%
hit
20.0
new
6.0
_identifier
2.0
CRAP 10.7
« EPrints/Parser/OAI.pm ↑ Summary EPrints/Filter.pm »
1 package Logfile::EPrints::Mapping::DSpace;
2  
3 6 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 6 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 =head1 NAME
7  
8 Logfile::EPrints::Mapping::DSpace - Map DSpace logs to requests
9  
10 =head1 SYNOPSIS
11  
12 See L<Logfile::EPrints>.
13  
14 use Logfile::EPrints;
15  
16 my $parser = Logfile::EPrints::Parser->new(
17 handler => Logfile::EPrints::Mapping::DSpace->new(
18 identifier => 'oai:dspace:',
19 handler => MyHandler->new
20 ));
21  
22 $parser->parse_fh( $fh );
23  
24 =head1 CAVEATS
25  
26 This module only supports abstract and fulltext.
27  
28 DSpace uses the exact same URL layout for communities as it does papers, so there's no way to distinguish them from just the log files. Community hits therefore come out as 'abstract' hits.
29  
30 =cut
31  
32 sub new
33 0 ▶{
Subroutine new: not called CC=2 SCAR=17.9
Pod undocumented
34 0 my( $class, %self ) = @_;
35  
36 0 ▶ Carp::croak(__PACKAGE__." requires identifier argument") unless exists $self{identifier};
Branch: 1 branch
BranchTrueFalseTotal
unless exists $self{"identifier"} 0 0 0
37  
38 0 bless \%self, $class;
39 }
40  
41 sub hit
42 0 ▶{
Subroutine hit: not called CC=4 SCAR=30.0
Pod undocumented
43 0 my( $self, $hit ) = @_;
44  
45 0 my $page = $hit->page;
46  
47 0 ▶ if( not defined $page )
Branch: 3 branches
BranchTrueFalseTotal
if (not defined $page) { } 0 0 0
elsif ($page =~ m[/handle/(\d+)/(\d+)$]) { } 0 0 0
elsif ($page =~ m[/bitstream/(\d+)/(\d+)/(\d+)/]) { } 0 0 0
48 {
49 0 warn "Hmm, error parsing hit - no page request found in: ".$hit->raw."\n";
50 }
51 # Abstract or community page
52 elsif( $page =~ /\/handle\/(\d+)\/(\d+)$/ )
53 {
54 0 $hit->{identifier} = $self->_identifier( $1, $2 );
55 0 $self->{handler}->abstract( $hit );
56 }
57 # Bitstream /dspace/bitstream/2160/229/1/Holocene+environments+faynan.pdf
58 elsif( $page =~ /\/bitstream\/(\d+)\/(\d+)\/(\d+)\// )
59 {
60 0 $hit->{identifier} = $self->_identifier( $1, $2 );
61 0 $self->{handler}->fulltext( $hit );
62 }
63 # Browse /dspace/browse-date?top=2160%2F161
64 # elsif( $page =~ /\/browse-(\w+)(?:\?|$)/ )
65 # {
66 # }
67 # Items-by /dspace/items-by-author?author=Pearce%2C+Jake&order=date
68 # elsif( $page =~ /\/items-by-(\w+)(?:\?|$)/ )
69 # {
70 # }
71 # Feedback /dspace/feedback?fromPage=http%3A%2F%2Fcadair.aber.ac.uk%2Fdspace%2Fbrowse-title%3Fstarts_with%3DI
72 # elsif( $page =~ /\/feedback\?/ )
73 # {
74 # }
75 # static /dspace/image/arrow.gif
76 # elsif( $page =~ /\/image\/([^\/]+)$/ or $page =~ /styles.css.jsp|robots.txt|utils.js$/ )
77 # {
78 # }
79 # else
80 # {
81 # print STDERR "Unhandled hit: ".$hit->raw."\n";
82 # }
83 }
84  
85 sub _identifier
86 0 ▶{
Subroutine _identifier: not called CC=1 SCAR=6.9
87 0 my( $self, $repo, $item ) = @_;
88  
89 0 return $self->{identifier} . "$repo/$item";
90 }
91  
92 6 1;
« EPrints/Parser/OAI.pm ↑ Summary EPrints/Filter.pm »