blib/lib/Net/OAI/ResumptionToken.pm

filter: Statementstmt 49.1% 30 / 61 Branchbran 18.7% 6 / 32 Conditioncond 33.3% 1 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 61.5% 8 / 13 Podpod 100% 9 / 9 totaltotal 45.0% 54 / 120 SCAR 45.3
CC
18
Cov
39%
start_element
56.0
end_element
20.0
start_prefix_mapping
12.0
CRAP 93.2
« blib/lib/Net/OAI/Error.pm ↑ Summary blib/lib/Net/OAI/Identify.pm »
1 package Net::OAI::ResumptionToken;
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 );
Subroutine BEGIN: called CC=1 SCAR=0.0
6 17 ▶use Carp qw( carp );
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8  
9 =head1 NAME
10  
11 Net::OAI::ResumptionToken - An OAI-PMH resumption token.
12  
13 =head1 SYNOPSIS
14  
15 =head1 DESCRIPTION
16  
17 This SAX filter records resumption token elements.
18  
19 =head1 METHODS
20  
21 =head2 new()
22  
23 =cut
24  
25 sub new {
26 1 ▶ my ( $class, %opts ) = @_;
Subroutine new: called CC=2 SCAR=7.2
Pod documented
27 1 ▶ my $self = bless \%opts, ref( $class ) || $class;
Condition33%1/3
ref $class || $class
l!l&&r!l&&!r
010
MC/DC0%0/2
ref $class || $class
ref $class $class
Truth table33%1/3
A || B
A= ref $classB= $class
ABresult
1X1
011
000
28 1 $self->{ _insideResumptionToken } = 0;
29 1 $self->{ token } = $self->{ expirationDate } = $self->{ completeListSize } = $self->{ cursor } = undef;
30 1 return( $self );
31 }
32  
33 =head2 token()
34  
35 (Sets and) returns the contents of the resumptionToken element.
36  
37 All methods return C<undef> if no token was encountered.
38  
39 =cut
40  
41 sub token {
42 0 ▶ my ( $self, $token ) = @_;
Subroutine token: not called CC=2 SCAR=17.9
Pod documented
43 0 ▶ if ( $token ) { $self->{ token } = $token; }
Branch: 1 branch
BranchTrueFalseTotal
if ($token) 0 0 0
44 0 return( $self->{ resumptionTokenText } );
45 }
46  
47 =head2 expirationDate()
48  
49 =cut
50  
51 sub expirationDate {
52 2 ▶ my ( $self, $date ) = @_;
Subroutine expirationDate: called CC=2 SCAR=6.9
Pod documented
53 2 ▶ if ( $date ) { $self->{ expirationDate } = $date; }
Branch: 1 branch
BranchTrueFalseTotal
if ($date) 1 1 2
54 2 return( $self->{ expirationDate } );
55 }
56  
57 =head2 completeListSize()
58  
59 =cut
60  
61 sub completeListSize {
62 2 ▶ my ( $self, $size ) = @_;
Subroutine completeListSize: called CC=2 SCAR=6.9
Pod documented
63 2 ▶ if ( $size ) { $self->{ completeListSize } = $size; }
Branch: 1 branch
BranchTrueFalseTotal
if ($size) 1 1 2
64 2 return( $self->{ completeListSize } );
65 }
66  
67 =head2 cursor()
68  
69 =cut
70  
71 sub cursor {
72 2 ▶ my ( $self, $cursor ) = @_;
Subroutine cursor: called CC=2 SCAR=6.9
Pod documented
73 2 ▶ if ( $cursor ) { $self->{ cursor } = $cursor; }
Branch: 1 branch
BranchTrueFalseTotal
if ($cursor) 1 1 2
74 2 return( $self->{ cursor } );
75 }
76  
77  
78 =head1 AUTHORS
79  
80 Ed Summers <ehs@pobox.com>
81  
82 =cut
83  
84 ## internal stuff
85  
86 ## all children of Net::OAI::Base should call this to make sure
87 ## certain object properties are set
88 sub start_prefix_mapping {
89 0 ▶ my ($self, $mapping) = @_;
Subroutine start_prefix_mapping: not called CC=3 SCAR=24.8
Pod documented
90 0 ▶ die "rT: self not defined" unless defined $self;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $self 0 0 0
91 0 ▶ return $self->SUPER::start_prefix_mapping( $mapping ) if $self->get_handler();
Branch: 1 branch
BranchTrueFalseTotal
if $self->get_handler 0 0 0
92 0 die "rT: start_prefix_mapping @{[$mapping]} w/o Handler";
93 }
94  
95  
96 sub start_element {
97 0 ▶ my ( $self, $element ) = @_;
Subroutine start_element: not called CC=7 SCAR=40.3
Pod documented
98 0 ▶ return $self->SUPER::start_element( $element ) unless $element->{NamespaceURI} eq Net::OAI::Harvester::XMLNS_OAI;
Branch: 1 branch
BranchTrueFalseTotal
unless $element->{"NamespaceURI"} eq "http://www.openarchives.org/OAI/2.0/" 0 0 0
99  
100 0 ▶ if ( $element->{ LocalName } eq 'resumptionToken' ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($element->{'LocalName'} eq 'resumptionToken') { } 0 0 0
elsif ($self->{'_insideResumptionToken'}) { } 0 0 0
101 0 my $attr = $element->{ Attributes };
102 0 ▶ $self->{ expirationDate } = $attr->{ '{}expirationDate' }{ Value } if $attr->{ '{}expirationDate' };
Branch: 1 branch
BranchTrueFalseTotal
if $attr->{"{}expirationDate"} 0 0 0
103 0 ▶ $self->{ completeListSize } = $attr->{ '{}completeListSize' }{ Value } if $attr->{ '{}completeListSize' };
Branch: 1 branch
BranchTrueFalseTotal
if $attr->{"{}completeListSize"} 0 0 0
104 0 ▶ $self->{ cursor } = $attr->{ '{}cursor' }{ Value } if $attr->{ '{}cursor' };
Branch: 1 branch
BranchTrueFalseTotal
if $attr->{"{}cursor"} 0 0 0
105 0 $self->{ resumptionTokenText } = "";
106 0 $self->{ _insideResumptionToken } = 1;
107 } elsif ( $self->{ _insideResumptionToken } ) {
108 0 carp "start of unhandled subelement ".$element->{ Name }." within resumptionToken";
109 } else {
110 0 $self->SUPER::start_element( $element );
111 }
112 }
113  
114 sub end_element {
115 0 ▶ my ( $self, $element ) = @_;
Subroutine end_element: not called CC=4 SCAR=30.0
Pod documented
116 0 ▶ return $self->SUPER::end_element( $element ) unless $element->{NamespaceURI} eq Net::OAI::Harvester::XMLNS_OAI;
Branch: 1 branch
BranchTrueFalseTotal
unless $element->{"NamespaceURI"} eq "http://www.openarchives.org/OAI/2.0/" 0 0 0
117  
118 0 ▶ if ( $element->{ LocalName } eq 'resumptionToken' ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($element->{'LocalName'} eq 'resumptionToken') { } 0 0 0
elsif ($self->{'_insideResumptionToken'}) { } 0 0 0
119 0 Net::OAI::Harvester::debug( "caught resumption token" );
120 0 $self->{ _insideResumptionToken } = 0;
121 } elsif ( $self->{ _insideResumptionToken } ) {
122 0 carp "end of unhandled subelement ".$element->{ Name }." within resumptionToken";
123 } else {
124 0 $self->SUPER::end_element( $element );
125 }
126 }
127  
128 sub characters {
129 0 ▶ my ( $self, $characters ) = @_;
Subroutine characters: not called CC=2 SCAR=17.9
Pod documented
130  
131 0 ▶ if ( $self->{ _insideResumptionToken } ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'_insideResumptionToken'}) { } 0 0 0
132 0 $self->{ resumptionTokenText } .= $characters->{ Data };
133 } else {
134 0 $self->SUPER::characters( $characters );
135 }
136 }
137  
138 17 1;
139  
« blib/lib/Net/OAI/Error.pm ↑ Summary blib/lib/Net/OAI/Identify.pm »