blib/lib/Net/OAI/Identify.pm

filter: Statementstmt 34.7% 24 / 69 Branchbran 0.0% 0 / 18 Conditioncond 33.3% 1 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 26.6% 4 / 15 Podpod 100% 12 / 12 totaltotal 34.4% 41 / 119 SCAR 40.4
CC
11
Cov
28%
end_element
30.0
start_element
12.0
adminEmail
6.0
CRAP 56.6
« blib/lib/Net/OAI/ResumptionToken.pm ↑ Summary blib/lib/Net/OAI/ListIdentifiers.pm »
1 package Net::OAI::Identify;
2  
3 17 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 17 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 17 ▶use base qw( XML::SAX::Base Net::OAI::Base );
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 =head1 NAME
8  
9 Net::OAI::Identify - Results of the Identify OAI-PMH verb.
10  
11 =head1 SYNOPSIS
12  
13 =head1 DESCRIPTION
14  
15 =head1 METHODS
16  
17 =head2 new()
18  
19 =cut
20  
21 sub new {
22 6 ▶ my ( $class, %opts ) = @_;
Subroutine new: called CC=2 SCAR=7.0
Pod documented
23 6 ▶ my $self = bless \%opts, ref( $class ) || $class;
Condition33%1/3
ref $class || $class
l!l&&r!l&&!r
060
MC/DC0%0/2
ref $class || $class
ref $class $class
Truth table33%1/3
A || B
A= ref $classB= $class
ABresult
1X1
011
000
24 6 $self->{ repositoryName } = '';
25 6 $self->{ baseUrl } = '';
26 6 $self->{ protocolVersion } = '';
27 6 $self->{ earliestDatestamp } = '';
28 6 $self->{ deletedRecord } = '';
29 6 $self->{ granularity } = '';
30 6 $self->{ adminEmail } = '';
31 6 $self->{ adminEmails } = [];
32 6 $self->{ compression } = '';
33 6 $self->{ compressions } = [];
34 6 $self->{ _insideDescription } = 0;
35 6 return( $self );
36 }
37  
38 =head2 repositoryName()
39  
40 Returns the name of the repostiory.
41  
42 =cut
43  
44 sub repositoryName {
45 0 ▶ my $self = shift;
Subroutine repositoryName: not called CC=1 SCAR=6.9
Pod documented
46 0 return( $self->{ repositoryName } );
47 }
48  
49 =head2 baseURL()
50  
51 Returns the base URL used by the repository.
52  
53 =cut
54  
55 sub baseURL {
56 0 ▶ my $self = shift;
Subroutine baseURL: not called CC=1 SCAR=6.9
Pod documented
57 0 return( $self->{ baseURL } );
58 }
59  
60 =head2 protocolVersion()
61  
62 Returns the version of the OAI-PMH used by the repository.
63  
64 =cut
65  
66 sub protocolVersion {
67 0 ▶ my $self = shift;
Subroutine protocolVersion: not called CC=1 SCAR=6.9
Pod documented
68 0 return( $self->{ protocolVersion } );
69 }
70  
71 =head2 earliestDatestamp()
72  
73 Returns the earlies datestamp for records available in the repository.
74  
75 =cut
76  
77 sub earliestDatestamp {
78 0 ▶ my $self = shift;
Subroutine earliestDatestamp: not called CC=1 SCAR=6.9
Pod documented
79 0 return( $self->{ earliestDatestamp } );
80 }
81  
82 =head2 deletedRecord()
83  
84 Indicates the way the repository works with deleted records. Should
85 return I<no>, I<transient> or I<persistent>.
86  
87 =cut
88  
89 sub deletedRecord {
90 0 ▶ my $self = shift;
Subroutine deletedRecord: not called CC=1 SCAR=6.9
Pod documented
91 0 return( $self->{ deletedRecord } );
92 }
93  
94 =head2 granularity()
95  
96 Returns the granularity used by the repository.
97  
98 =cut
99  
100 sub granularity {
101 0 ▶ my $self = shift;
Subroutine granularity: not called CC=1 SCAR=6.9
Pod documented
102 0 return( $self->{ granularity } );
103 }
104  
105 =head2 adminEmail()
106  
107 Returns the administrative email address for the repository. Since the
108 adminEmail elelemnt is allowed to repeat you will get all the emails (if more
109 than one are specified) by using adminEmail in a list context.
110  
111 $email = $identity->adminEmail();
112 @emails = $identity->adminEmails();
113  
114 =cut
115  
116 sub adminEmail {
117 0 ▶ my $self = shift;
Subroutine adminEmail: not called CC=2 SCAR=17.9
Pod documented
118 0 ▶ if ( wantarray() ) { return( @{ $self->{ adminEmails } } ); }
Branch: 1 branch
BranchTrueFalseTotal
if (wantarray) 0 0 0
119 0 return( $self->{ adminEmails }[ 0 ] );
120 }
121  
122 =head2 compression()
123  
124 Returns the types of compression that the archive supports. Since the
125 compression element may repeat you may get all the values by using
126 compression() in a list context.
127  
128 $compression = $identity->compression();
129 @compressions = $identity->compressions();
130  
131 =cut
132  
133 sub compression {
134 0 ▶ my $self = shift;
Subroutine compression: not called CC=2 SCAR=17.9
Pod documented
135 0 ▶ if ( wantarray() ) { return( @{ $self->{ compressions } } ); }
Branch: 1 branch
BranchTrueFalseTotal
if (wantarray) 0 0 0
136 0 return( $self->{ compressions }[ 0 ] );
137 }
138  
139 =head1 TODO
140  
141 Support for the various C<description> containers.
142  
143 =cut
144  
145 ## SAX Handlers
146  
147 sub start_element {
148 0 ▶ my ( $self, $element ) = @_;
Subroutine start_element: not called CC=3 SCAR=24.8
Pod documented
149 0 ▶ return $self->SUPER::start_element($element) unless $element->{NamespaceURI} eq Net::OAI::Harvester::XMLNS_OAI; # should be error?
Branch: 1 branch
BranchTrueFalseTotal
unless $element->{"NamespaceURI"} eq "http://www.openarchives.org/OAI/2.0/" 0 0 0
150  
151 0 push( @{ $self->{ tagStack } }, $element->{ LocalName } );
152 0 ▶ $self->{ _insideDescription } = 1 if $element->{ LocalName } eq 'description';
Branch: 1 branch
BranchTrueFalseTotal
if $element->{"LocalName"} eq "description" 0 0 0
153 }
154  
155 sub end_element {
156 0 ▶ my ( $self, $element ) = @_;
Subroutine end_element: not called CC=5 SCAR=34.0
Pod documented
157 0 ▶ return $self->SUPER::end_element($element) unless $element->{NamespaceURI} eq Net::OAI::Harvester::XMLNS_OAI; # should be error?
Branch: 1 branch
BranchTrueFalseTotal
unless $element->{"NamespaceURI"} eq "http://www.openarchives.org/OAI/2.0/" 0 0 0
158  
159 ## store and reset elements that can have multiple values
160 0 ▶ if ( $element->{ LocalName } eq 'adminEmail' ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($element->{'LocalName'} eq 'adminEmail') { } 0 0 0
elsif ($element->{'LocalName'} eq 'compression') { } 0 0 0
161 0 Net::OAI::Harvester::debug( "got adminEmail in Identify" );
162 0 push( @{ $self->{ adminEmails } }, $self->{ adminEmail } );
163 0 $self->{ adminEmail } = '';
164 }
165 elsif ( $element->{ LocalName } eq 'compression' ) {
166 0 Net::OAI::Harvester::debug( "got compression in Identify" );
167 0 push( @{ $self->{ compressions } }, $self->{ compression } );
168 0 $self->{ compression } = '';
169 }
170 0 pop( @{ $self->{ tagStack } } );
171 0 ▶ $self->{ _insideDescription } = 0 if $element->{ LocalName } eq 'description';
Branch: 1 branch
BranchTrueFalseTotal
if $element->{"LocalName"} eq "description" 0 0 0
172 }
173  
174 sub characters {
175 0 ▶ my ( $self, $characters ) = @_;
Subroutine characters: not called CC=2 SCAR=17.9
Pod documented
176  
177 0 ▶ if ( $self->{ _insideDescription } ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'_insideDescription'}) { } 0 0 0
178 0 return $self->SUPER::characters( $characters );
179 } else {
180 $self->{ $self->{ tagStack }[-1] } .= $characters->{ Data }
181 0 }
182 }
183  
184 17 1;
185  
« blib/lib/Net/OAI/ResumptionToken.pm ↑ Summary blib/lib/Net/OAI/ListIdentifiers.pm »