| 1 | package Catmandu::Exporter::PICA; | ||
| 2 | 1 | ▶ | use strict; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 3 | 1 | ▶ | use warnings; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 4 | |||
| 5 | 1 | ▶ | use Catmandu::Sane; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 6 | 1 | ▶ | use PICA::Data qw(pica_writer); |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 7 | 1 | ▶ | use Moo; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 8 | |||
| 9 | 1 | our $VERSION = '1.18'; | |
| 10 | |||
| 11 | 1 | with 'Catmandu::Exporter'; | |
| 12 | |||
| 13 | 0 | ▶ | has type => ( is => 'rw', default => sub { 'xml' } ); |
|
Subroutine
__ANON__: not called CC=1 SCAR=1.2
| |||
| 14 | 0 | ▶ | has subfield_indicator => ( is => 'rw', default => sub { '$' } ); |
|
Subroutine
__ANON__: not called CC=1 SCAR=1.2
| |||
| 15 | 0 | ▶ | has field_separator => ( is => 'rw', default => sub { "\n" } ); |
|
Subroutine
__ANON__: not called CC=1 SCAR=1.2
| |||
| 16 | 0 | ▶ | has record_separator => ( is => 'rw', default => sub { "\n" } ); |
|
Subroutine
__ANON__: not called CC=1 SCAR=1.2
| |||
| 17 | 1 | has writer => ( is => 'lazy' ); | |
| 18 | 1 | has annotate => ( is => 'rw' ); | |
| 19 | |||
| 20 | 0 | ▶ | sub _build_writer { |
|
Subroutine
_build_writer: not called CC=1 SCAR=6.9
| |||
| 21 | 0 | my ($self) = @_; | |
| 22 | 0 | pica_writer( | |
| 23 | $self->type, | ||
| 24 | fh => $self->fh, | ||
| 25 | us => $self->subfield_indicator, | ||
| 26 | rs => $self->field_separator, | ||
| 27 | gs => $self->record_separator, | ||
| 28 | annotate => $self->annotate, | ||
| 29 | ); | ||
| 30 | } | ||
| 31 | |||
| 32 | sub add { | ||
| 33 | my ( $self, $data ) = @_; | ||
| 34 | |||
| 35 | # utf8::decode ??? | ||
| 36 | $self->writer->write($data); | ||
| 37 | } | ||
| 38 | |||
| 39 | sub commit { | ||
| 40 | my ($self) = @_; | ||
| 41 | |||
| 42 | # collection element is optional for type xml | ||
| 43 | $self->writer->end if $self->writer->can('end'); | ||
| 44 | } | ||
| 45 | |||
| 46 | 1 | 1; | |
| 47 | __END__ | ||