line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Catmandu::Exporter::PICA; |
2
|
|
|
|
|
|
|
|
3
|
2
|
|
|
2
|
|
24522
|
use Catmandu::Sane; |
|
2
|
|
|
|
|
183750
|
|
|
2
|
|
|
|
|
28
|
|
4
|
2
|
|
|
2
|
|
2241
|
use PICA::Writer::Plus; |
|
2
|
|
|
|
|
140319
|
|
|
2
|
|
|
|
|
83
|
|
5
|
2
|
|
|
2
|
|
1322
|
use PICA::Writer::Plain; |
|
2
|
|
|
|
|
1510
|
|
|
2
|
|
|
|
|
62
|
|
6
|
2
|
|
|
2
|
|
1341
|
use PICA::Writer::XML; |
|
2
|
|
|
|
|
994
|
|
|
2
|
|
|
|
|
66
|
|
7
|
2
|
|
|
2
|
|
13
|
use Moo; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
21
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
our $VERSION = '0.17'; |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
with 'Catmandu::Exporter'; |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
has type => ( is => 'rw', default => sub { 'xml' } ); |
14
|
|
|
|
|
|
|
has writer => ( is => 'lazy' ); |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
sub _build_writer { |
17
|
3
|
|
|
3
|
|
424
|
my ($self) = @_; |
18
|
|
|
|
|
|
|
|
19
|
3
|
|
|
|
|
16
|
my $type = lc $self->type; |
20
|
|
|
|
|
|
|
|
21
|
3
|
100
|
|
|
|
18
|
if ( $type =~ /^(pica)?plus$/ ) { |
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
22
|
1
|
|
|
|
|
5
|
PICA::Writer::Plus->new( fh => $self->fh ); |
23
|
|
|
|
|
|
|
} elsif ( $type eq 'plain') { |
24
|
1
|
|
|
|
|
5
|
PICA::Writer::Plain->new( fh => $self->fh ); |
25
|
|
|
|
|
|
|
} elsif ( $type eq 'xml') { |
26
|
1
|
|
|
|
|
5
|
PICA::Writer::XML->new( fh => $self->fh ); |
27
|
|
|
|
|
|
|
} else { |
28
|
0
|
|
|
|
|
|
die "unknown type: $type"; |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
sub add { |
33
|
|
|
|
|
|
|
my ($self, $data) = @_; |
34
|
|
|
|
|
|
|
# utf8::decode ??? |
35
|
|
|
|
|
|
|
$self->writer->write($data); |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
sub commit { # TODO: why is this not called automatically? |
39
|
|
|
|
|
|
|
my ($self) = @_; |
40
|
|
|
|
|
|
|
$self->writer->end if $self->can('end'); |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
1; |
44
|
|
|
|
|
|
|
__END__ |