line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Catmandu::Importer::PICA; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
our $VERSION = '0.17'; |
4
|
|
|
|
|
|
|
|
5
|
5
|
|
|
5
|
|
1258442
|
use Catmandu::Sane; |
|
5
|
|
|
|
|
359011
|
|
|
5
|
|
|
|
|
43
|
|
6
|
5
|
|
|
5
|
|
4864
|
use PICA::Parser::XML; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
use PICA::Parser::Plus; |
8
|
|
|
|
|
|
|
use PICA::Parser::Plain; |
9
|
|
|
|
|
|
|
use Moo; |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
with 'Catmandu::Importer'; |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
has type => ( is => 'ro', default => sub { 'xml' } ); |
14
|
|
|
|
|
|
|
has parser => ( is => 'lazy' ); |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
sub _build_parser { |
17
|
|
|
|
|
|
|
my ($self) = @_; |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
my $type = lc $self->type; |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
if ( $type =~ /^(pica)?plus$/ ) { |
22
|
|
|
|
|
|
|
PICA::Parser::Plus->new( $self->fh ); |
23
|
|
|
|
|
|
|
} elsif ( $type eq 'plain') { |
24
|
|
|
|
|
|
|
PICA::Parser::Plain->new( $self->fh ); |
25
|
|
|
|
|
|
|
} elsif ( $type eq 'xml') { |
26
|
|
|
|
|
|
|
$self->{encoding} = ':raw'; # set encoding to :raw to drop PerlIO layers, as required by libxml2 |
27
|
|
|
|
|
|
|
PICA::Parser::XML->new( $self->fh ); |
28
|
|
|
|
|
|
|
} else { |
29
|
|
|
|
|
|
|
die "unknown type: $type"; |
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
sub generator { |
34
|
|
|
|
|
|
|
my ($self) = @_; |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
sub { |
37
|
|
|
|
|
|
|
return $self->parser->next(); |
38
|
|
|
|
|
|
|
}; |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
1; |
42
|
|
|
|
|
|
|
__END__ |