File Coverage

blib/lib/MARC/Moose/Reader/File/Marcxml.pm
Criterion Covered Total %
statement 21 21 100.0
branch 3 4 75.0
condition n/a
subroutine 5 5 100.0
pod 0 1 0.0
total 29 31 93.5


line stmt bran cond sub pod time code
1             package MARC::Moose::Reader::File::Marcxml;
2             # ABSTRACT: File reader for MARCXML file
3             $MARC::Moose::Reader::File::Marcxml::VERSION = '1.0.45';
4 2     2   2033 use Moose;
  2         5  
  2         17  
5              
6 2     2   13895 use Carp;
  2         7  
  2         156  
7 2     2   16 use MARC::Moose::Record;
  2         3  
  2         57  
8 2     2   12 use MARC::Moose::Parser::Marcxml;
  2         5  
  2         540  
9              
10             with 'MARC::Moose::Reader::File';
11              
12              
13              
14             has '+parser' => ( default => sub { MARC::Moose::Parser::MarcxmlSax->new() } );
15              
16              
17             sub read {
18 5     5 0 11 my $self = shift;
19              
20 5         171 $self->count($self->count + 1);
21              
22 5         125 my $fh = $self->{fh};
23              
24 5 50       888 return if eof($fh);
25              
26 5         24 local $/ = "</record>"; # End of record
27 5         138 my $raw = <$fh>;
28            
29             # Skip <collection if present
30 5         40 $raw =~ s/<(\/*)collection.*>//;
31              
32             # End of file
33 5 100       35 return unless $raw =~ /<record.*>/;
34              
35 4         154 $self->parser->parse( $raw );
36             }
37              
38             __PACKAGE__->meta->make_immutable;
39              
40             1;
41              
42             __END__
43              
44             =pod
45              
46             =encoding UTF-8
47              
48             =head1 NAME
49              
50             MARC::Moose::Reader::File::Marcxml - File reader for MARCXML file
51              
52             =head1 VERSION
53              
54             version 1.0.45
55              
56             =head1 DESCRIPTION
57              
58             Override L<MARC::Moose::Reader::File>, and read a file containing MARCXML
59             records.
60              
61             =head1 ATTRIBUTES
62              
63             =head2 parser
64              
65             By default, a L<MARC::Moose::Parser::MarcxmlSax> parser is used.
66              
67             =head1 AUTHOR
68              
69             Frédéric Demians <f.demians@tamil.fr>
70              
71             =head1 COPYRIGHT AND LICENSE
72              
73             This software is copyright (c) 2022 by Frédéric Demians.
74              
75             This is free software; you can redistribute it and/or modify it under
76             the same terms as the Perl 5 programming language system itself.
77              
78             =cut