| 1 | package MARC::Moose::Reader::String::Iso2709; | ||||||||||
| 2 | # ABSTRACT: File reader for MARC::Moose record from ISO2709 string | ||||||||||
| 3 | 2 | $MARC::Moose::Reader::String::Iso2709::VERSION = '1.0.49'; | |||||||||
| 4 | 2 | ▶ | use Moose; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 5 | |||||||||||
| 6 | 2 | ▶ | use Carp; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 7 | 2 | ▶ | use MARC::Moose::Record; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 8 | 2 | ▶ | use MARC::Moose::Parser::Iso2709; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 9 | |||||||||||
| 10 | 2 | with 'MARC::Moose::Reader::String'; | |||||||||
| 11 | |||||||||||
| 12 | |||||||||||
| 13 | has parser => ( | ||||||||||
| 14 | is => 'rw', | ||||||||||
| 15 | isa => 'MARC::Moose::Parser', | ||||||||||
| 16 | 1 | ▶ | default => sub { MARC::Moose::Parser::Iso2709->new() }, | ||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||
| 17 | 2 | ); | |||||||||
| 18 | |||||||||||
| 19 | # An arrayref of all ISO2709 MARC record found in the string | ||||||||||
| 20 | 2 | has records => ( is => 'rw', isa => 'ArrayRef' ); | |||||||||
| 21 | |||||||||||
| 22 | |||||||||||
| 23 | 1 | ▶ | sub BUILD { | ||||||||
|
Subroutine
BUILD: called CC=2 SCAR=7.0
Pod
undocumented
| |||||||||||
| 24 | 1 | my $self = shift; | |||||||||
| 25 | |||||||||||
| 26 | 1 | my @records = split /\x1d/, $self->string; | |||||||||
| 27 | 1 | $self->records( \@records ); | |||||||||
| 28 | |||||||||||
| 29 | # Pop last entry which empty | ||||||||||
| 30 | 1 | ▶ | if ( @records ) { pop @records }; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 31 | } | ||||||||||
| 32 | |||||||||||
| 33 | |||||||||||
| 34 | |||||||||||
| 35 | 2 | ▶ | sub read { | ||||||||
|
Subroutine
read: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||
| 36 | 2 | my $self = shift; | |||||||||
| 37 | |||||||||||
| 38 | 2 | my $count = $self->count; | |||||||||
| 39 | 2 | ▶ | return if $count == @{ $self->records }; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 40 | |||||||||||
| 41 | 1 | my $raw = $self->records->[$count]; | |||||||||
| 42 | # remove illegal garbage that sometimes occurs between records | ||||||||||
| 43 | 1 | $raw =~ s/^[ \x00\x0a\x0d\x1a]+//; | |||||||||
| 44 | 1 | my $record = $self->parser->parse( $raw ); | |||||||||
| 45 | 1 | $count++; | |||||||||
| 46 | 1 | $self->count( $count ); | |||||||||
| 47 | 1 | return $record; | |||||||||
| 48 | } | ||||||||||
| 49 | |||||||||||
| 50 | 2 | __PACKAGE__->meta->make_immutable; | |||||||||
| 51 | |||||||||||
| 52 | 2 | 1; | |||||||||
| 53 | |||||||||||
| 54 | __END__ | ||||||||||