| 1 | package HTTP::OAI::Verb; | ||||||||||||||
| 2 | |||||||||||||||
| 3 | 11 | @ISA = qw( HTTP::OAI::MemberMixin HTTP::OAI::SAX::Base ); | |||||||||||||
| 4 | |||||||||||||||
| 5 | 11 | ▶ | use strict; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 6 | |||||||||||||||
| 7 | 11 | our $VERSION = '4.13'; | |||||||||||||
| 8 | |||||||||||||||
| 9 | # back compatibility | ||||||||||||||
| 10 | 2 | ▶ | sub toDOM { | ||||||||||||
|
Subroutine
toDOM: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||
| 11 | 2 | shift->dom; | |||||||||||||
| 12 | } | ||||||||||||||
| 13 | |||||||||||||||
| 14 | 0 | ▶ | sub errors { | ||||||||||||
|
Subroutine
errors: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||
| 15 | 0 | shift->_multi('error',@_); | |||||||||||||
| 16 | } | ||||||||||||||
| 17 | |||||||||||||||
| 18 | 2 | ▶ | sub xslt { | ||||||||||||
|
Subroutine
xslt: called CC=2 SCAR=7.1
Pod
undocumented
| |||||||||||||||
| 19 | 2 | my ($self,$xslt) = @_; | |||||||||||||
| 20 | 2 | ▶ | $self->{xslt} = $xslt if defined($xslt); | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 21 | 2 | $self->{xslt}; | |||||||||||||
| 22 | } | ||||||||||||||
| 23 | |||||||||||||||
| 24 | 11 | for(qw( parse_string parse_file )) | |||||||||||||
| 25 | { | ||||||||||||||
| 26 | 11 | ▶ | no strict; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 27 | 22 | my $fn = $_; | |||||||||||||
| 28 | 6 | ▶ | *$fn = sub { | ||||||||||||
|
Subroutine
__ANON__: called CC=3 SCAR=12.0
| |||||||||||||||
| 29 | 6 | my( $self, $io ) = @_; | |||||||||||||
| 30 | |||||||||||||||
| 31 | my $r = HTTP::OAI::Response->new( | ||||||||||||||
| 32 | verb => $self->verb, | ||||||||||||||
| 33 | handlers => $self->{handlers}, | ||||||||||||||
| 34 | 6 | ); | |||||||||||||
| 35 | 6 | $r->$fn( $io ); | |||||||||||||
| 36 | 6 | ▶ | if( $r->is_error ) | ||||||||||||
|
Branch: 2 branches
| |||||||||||||||
| 37 | { | ||||||||||||||
| 38 | 0 | die "Error parsing: ".$r->code." ".$r->message; | |||||||||||||
| 39 | } | ||||||||||||||
| 40 | elsif( $r->error ) | ||||||||||||||
| 41 | { | ||||||||||||||
| 42 | 0 | $self->errors( $r->error ); | |||||||||||||
| 43 | } | ||||||||||||||
| 44 | else | ||||||||||||||
| 45 | { | ||||||||||||||
| 46 | 6 | my $content = ($r->content)[-1]; | |||||||||||||
| 47 | # HACK HACK HACK | ||||||||||||||
| 48 | 6 | %$self = %$content; | |||||||||||||
| 49 | } | ||||||||||||||
| 50 | 22 | }; | |||||||||||||
| 51 | } | ||||||||||||||
| 52 | |||||||||||||||
| 53 | sub verb | ||||||||||||||
| 54 | 10 | ▶ | { | ||||||||||||
|
Subroutine
verb: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||
| 55 | 10 | my $class = ref($_[0]); | |||||||||||||
| 56 | 10 | $class =~ s/^.*:://; | |||||||||||||
| 57 | 10 | return $class; | |||||||||||||
| 58 | } | ||||||||||||||
| 59 | |||||||||||||||
| 60 | sub generate | ||||||||||||||
| 61 | 2 | ▶ | { | ||||||||||||
|
Subroutine
generate: called CC=2 SCAR=7.1
Pod
undocumented
| |||||||||||||||
| 62 | 2 | my( $self, $driver ) = @_; | |||||||||||||
| 63 | |||||||||||||||
| 64 | 2 | ▶ | if( $self->xslt ) { | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 65 | 0 | $driver->processing_instruction({ | |||||||||||||
| 66 | 'Target' => 'xml-stylesheet', | ||||||||||||||
| 67 | 'Data' => 'type=\'text/xsl\' href=\''. $self->xslt . '\'' | ||||||||||||||
| 68 | }); | ||||||||||||||
| 69 | } | ||||||||||||||
| 70 | |||||||||||||||
| 71 | 2 | $driver->start_element( 'OAI-PMH', | |||||||||||||
| 72 | 'xsi:schemaLocation' => 'http://www.openarchives.org/OAI/2.0/ http://www.openarchives.org/OAI/2.0/OAI-PMH.xsd', | ||||||||||||||
| 73 | ); | ||||||||||||||
| 74 | 2 | $driver->start_element( $self->verb ); | |||||||||||||
| 75 | 2 | $self->generate_body( $driver ); | |||||||||||||
| 76 | 2 | $driver->end_element( $self->verb ); | |||||||||||||
| 77 | 2 | $driver->end_element( 'OAI-PMH' ); | |||||||||||||
| 78 | } | ||||||||||||||
| 79 | |||||||||||||||
| 80 | 11 | 1; | |||||||||||||