line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Catmandu::Exporter::PICA; |
2
|
|
|
|
|
|
|
|
3
|
2
|
|
|
2
|
|
23359
|
use Catmandu::Sane; |
|
2
|
|
|
|
|
93072
|
|
|
2
|
|
|
|
|
43
|
|
4
|
2
|
|
|
2
|
|
2885
|
use PICA::Writer::Plus; |
|
2
|
|
|
|
|
117217
|
|
|
2
|
|
|
|
|
87
|
|
5
|
2
|
|
|
2
|
|
1454
|
use PICA::Writer::Plain; |
|
2
|
|
|
|
|
1630
|
|
|
2
|
|
|
|
|
67
|
|
6
|
2
|
|
|
2
|
|
1420
|
use PICA::Writer::XML; |
|
2
|
|
|
|
|
1078
|
|
|
2
|
|
|
|
|
64
|
|
7
|
2
|
|
|
2
|
|
13
|
use Moo; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
21
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
our $VERSION = '0.16'; |
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
|
|
460
|
my ($self) = @_; |
18
|
|
|
|
|
|
|
|
19
|
3
|
|
|
|
|
20
|
my $type = lc $self->type; |
20
|
|
|
|
|
|
|
|
21
|
3
|
100
|
|
|
|
20
|
if ( $type =~ /^(pica)?plus$/ ) { |
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
22
|
1
|
|
|
|
|
6
|
PICA::Writer::Plus->new( fh => $self->fh ); |
23
|
|
|
|
|
|
|
} elsif ( $type eq 'plain') { |
24
|
1
|
|
|
|
|
4
|
PICA::Writer::Plain->new( fh => $self->fh ); |
25
|
|
|
|
|
|
|
} elsif ( $type eq 'xml') { |
26
|
1
|
|
|
|
|
4
|
PICA::Writer::XML->new( fh => $self->fh ); |
27
|
|
|
|
|
|
|
} else { |
28
|
0
|
|
|
|
|
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
|
3
|
|
|
3
|
0
|
330
|
my ($self) = @_; |
40
|
3
|
50
|
|
|
|
23
|
$self->writer->end if $self->can('end'); |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
1; |
44
|
|
|
|
|
|
|
__END__ |