File Coverage

blib/lib/Catmandu/AlephX/Op/IllGetDoc.pm
Criterion Covered Total %
statement 15 24 62.5
branch 0 2 0.0
condition n/a
subroutine 5 8 62.5
pod 0 2 0.0
total 20 36 55.5


line stmt bran cond sub pod time code
1             package Catmandu::AlephX::Op::IllGetDoc;
2 1     1   86643 use Catmandu::Sane;
  1         162612  
  1         7  
3 1     1   303 use Catmandu::Util qw(:check);
  1         2  
  1         255  
4 1     1   519 use Catmandu::AlephX::Metadata::MARC;
  1         2  
  1         33  
5 1     1   376 use Catmandu::AlephX::Record;
  1         3  
  1         40  
6 1     1   6 use Moo;
  1         2  
  1         3  
7              
8             our $VERSION = "1.072";
9              
10             with('Catmandu::AlephX::Response');
11              
12             #<doc> has extra tag in marc array called 'AVA'
13             has record => (
14             is => 'ro',
15             isa => sub { check_instance($_[0],"Catmandu::AlephX::Record"); }
16             );
17 0     0 0   sub op { 'ill-get-doc' }
18              
19             sub parse {
20 0     0 0   my($class,$str_ref) = @_;
21              
22 0           my $xpath = xpath($str_ref);
23 0           my $op = op();
24              
25             __PACKAGE__->new(
26             errors => $class->parse_errors($xpath),
27             session_id => $xpath->findvalue("/$op/session-id"),
28             record => Catmandu::AlephX::Record->new(metadata => sub {
29 0     0     $xpath->registerNs("marc","http://www.loc.gov/MARC21/slim/");
30 0           my($marc) = $xpath->find("/$op/marc:record")->get_nodelist();
31 0 0         if($marc){
32             #remove controlfield with tag 'FMT' and 'LDR' because Catmandu::Importer::MARC cannot handle these
33 0           return Catmandu::AlephX::Metadata::MARC->parse($marc);
34             }
35 0           }),
36             content_ref => $str_ref
37             );
38             }
39              
40             1;