blib/lib/Net/OAI/ListMetadataFormats.pm

filter: Statementstmt 28.5% 20 / 70 Branchbran 0.0% 0 / 26 Conditioncond 33.3% 1 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 38.4% 5 / 13 Podpod 100% 9 / 9 totaltotal 28.4% 35 / 123 SCAR 48.3
CC
15
Cov
21%
end_element
90.0
start_element
30.0
characters
6.0
CRAP 125.0
« blib/lib/Net/OAI/ListRecords.pm ↑ Summary blib/lib/Net/OAI/Error.pm »
1 package Net::OAI::ListMetadataFormats;
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 17 ▶use Carp qw( carp );
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 =head1 NAME
9  
10 Net::OAI::ListMetadataFormats - Results of the ListMetadataFormats OAI-PMH verb.
11  
12 =head1 SYNOPSIS
13  
14 =head1 DESCRIPTION
15  
16 =head1 METHODS
17  
18 =head2 new()
19  
20 =cut
21  
22 sub new {
23 2 ▶ my ( $class, %opts ) = @_;
Subroutine new: called CC=2 SCAR=7.1
Pod documented
24 2 ▶ my $self = bless \%opts, ref( $class ) || $class;
Condition33%1/3
ref $class || $class
l!l&&r!l&&!r
020
MC/DC0%0/2
ref $class || $class
ref $class $class
Truth table33%1/3
A || B
A= ref $classB= $class
ABresult
1X1
011
000
25 2 $self->{ _insideList } = 0;
26 2 $self->{ metadataPrefixes } = [];
27 2 $self->{ namespaces } = [];
28 2 $self->{ schemas } = [];
29 2 return( $self );
30 }
31  
32 =head2 prefixes()
33  
34 =cut
35  
36 sub prefixes() {
37 0 ▶ my $self = shift;
Subroutine prefixes: not called CC=1 SCAR=6.9
Pod documented
38 0 return( @{ $self->{ metadataPrefixes } } );
39 }
40  
41 =head2 namespaces()
42  
43 =cut
44  
45 sub namespaces {
46 0 ▶ my $self = shift;
Subroutine namespaces: not called CC=1 SCAR=6.9
Pod documented
47 0 return( @{ $self->{ namespaces } } );
48 }
49  
50 =head2 namespaces_byprefix()
51  
52 Returns the namespace URI associated to a given metadataPrefix.
53  
54 =cut
55  
56 sub namespaces_byprefix {
57 0 ▶ my ($self, $prefix) = @_;
Subroutine namespaces_byprefix: not called CC=1 SCAR=6.9
Pod documented
58 0 return $self->{namespaces_byprefix}->{$prefix};
59 }
60  
61  
62 =head2 schemas()
63  
64 =cut
65  
66 sub schemas {
67 0 ▶ my $self = shift;
Subroutine schemas: not called CC=1 SCAR=6.9
Pod documented
68 0 return( @{ $self->{ schemas } } );
69 }
70  
71 =head2 schemas_byprefix()
72  
73 Returns the schema URI associated to a given metadataPrefix.
74  
75 =cut
76  
77 sub schemas_byprefix {
78 0 ▶ my ($self, $prefix) = @_;
Subroutine schemas_byprefix: not called CC=1 SCAR=6.9
Pod documented
79 0 return $self->{schemas_byprefix}->{$prefix};
80 }
81  
82 # SAX Handlers
83  
84 sub start_element {
85 0 ▶ my ( $self, $element ) = @_;
Subroutine start_element: not called CC=5 SCAR=34.0
Pod documented
86 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
87  
88 0 ▶ if ( $element->{ LocalName } eq 'ListMetadataFormats' ) {
Branch: 3 branches
BranchTrueFalseTotal
if ($element->{'LocalName'} eq 'ListMetadataFormats') { } 0 0 0
elsif ($self->{'_insideList'}) { } 0 0 0
elsif ($element->{'LocalName'} eq 'OAI-PMH') { } 0 0 0
89 0 $self->{ _insideList } = 1;
90 } elsif ( $self->{ _insideList } ) {
91 } elsif ( $element->{ LocalName } eq 'OAI-PMH' ) {
92 } else {
93 0 carp "who am I? (".$element->{ LocalName }.")";
94 0 $self->SUPER::start_element( $element );
95 }
96 0 push( @{ $self->{ tagStack } }, $element->{ LocalName } );
97 }
98  
99 sub end_element {
100 0 ▶ my ( $self, $element ) = @_;
Subroutine end_element: not called CC=9 SCAR=45.0
Pod documented
101 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
102  
103 0 my $name = $element->{ LocalName };
104 0 ▶ if ( $name eq 'ListMetadataFormats' ) {
Branch: 7 branches
BranchTrueFalseTotal
if ($name eq 'ListMetadataFormats') { } 0 0 0
elsif ($name eq 'metadataFormat') { } 0 0 0
elsif ($name eq 'metadataPrefix') { } 0 0 0
elsif ($name eq 'schema') { } 0 0 0
elsif ($name eq 'metadataNamespace') { } 0 0 0
elsif ($self->{'_insideList'}) { } 0 0 0
elsif ($element->{'LocalName'} eq 'OAI-PMH') { } 0 0 0
105 0 $self->{ _insideList } = 0;
106 } elsif ( $name eq 'metadataFormat' ) {
107 0 my $nspf = delete $self->{ _currpf };
108 0 $self->{ namespaces_byprefix }->{ $nspf } = delete $self->{ _currns };
109 0 $self->{ schemas_byprefix }->{ $nspf } = delete $self->{ _currxs };
110 } elsif ( $name eq 'metadataPrefix' ) {
111 0 push( @{ $self->{ metadataPrefixes } }, $self->{ metadataPrefix } );
112 0 $self->{ _currpf } = $self->{ metadataPrefix };
113 0 $self->{ metadataPrefix } = '';
114 } elsif ( $name eq 'schema' ) {
115 0 push( @{ $self->{ schemas } }, $self->{schema } );
116 0 $self->{ _currxs } = $self->{ schema };
117 0 $self->{ schema } = '';
118 } elsif ( $name eq 'metadataNamespace' ) {
119 0 push( @{ $self->{ namespaces } }, $self->{ metadataNamespace } );
120 0 $self->{ _currns } = $self->{ metadataNamespace };
121 0 $self->{ metadataNamespace } = '';
122 } elsif ( $self->{ _insideList } ) {
123 0 carp "who am I? ($name)";
124 } elsif ( $element->{ LocalName } eq 'OAI-PMH' ) {
125 } else {
126 0 carp "who am I? ($name)";
127 0 $self->SUPER::end_element( $element );
128 }
129 0 pop( @{ $self->{ tagStack } } );
130 }
131  
132 sub characters {
133 0 ▶ my ( $self, $characters ) = @_;
Subroutine characters: not called CC=2 SCAR=17.9
Pod documented
134 0 ▶ if ( $self->{ _insideList } ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'_insideList'}) { } 0 0 0
135 $self->{ $self->{ tagStack }[-1] } .= $characters->{ Data }
136 0 } else {
137 0 $self->SUPER::characters( $characters )};
138 }
139  
140 17 1;
« blib/lib/Net/OAI/ListRecords.pm ↑ Summary blib/lib/Net/OAI/Error.pm »