| 1 | package MARC::File::MiJ; | ||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | 1 | ▶ | use 5.006; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | 1 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | 1 | ▶ | use warnings FATAL => 'all'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||
| 7 | 1 | ▶ | use MARC::Record::MiJ; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 8 | 1 | ▶ | use base qw(MARC::File); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||
| 10 | =head1 NAME | ||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||
| 12 | MARC::File::MiJ - Read newline-delimited marc-in-json files | ||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||
| 14 | =head1 VERSION | ||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||
| 16 | Version 0.04 | ||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||
| 18 | =cut | ||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||
| 20 | 1 | our $VERSION = '0.04'; | |||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||
| 23 | =head1 SYNOPSIS | ||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||
| 25 | Use by itself or with MARC::Batch | ||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||
| 27 | use MARC::Batch; | ||||||||||||||||||||||||||||
| 28 | use MARC::File::MiJ; | ||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||
| 30 | my $reader = new MARC::Batch('MiJ', $jsonfilename); | ||||||||||||||||||||||||||||
| 31 | while (my $r = $batch->next) { ... } | ||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||
| 33 | # or, use it without MARC::Batch | ||||||||||||||||||||||||||||
| 34 | my $reader = MARC::File::MiJ->in($jsonfilename); | ||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||
| 36 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||
| 38 | A subclass of MARC::File for reading MARC records encoded as newline-delimited marc-in-json, | ||||||||||||||||||||||||||||
| 39 | as supported by pymarc/ruby-marc/marc4j and | ||||||||||||||||||||||||||||
| 40 | described at http://dilettantes.code4lib.org/blog/2010/09/a-proposal-to-serialize-marc-in-json/. | ||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||
| 44 | =head1 SUBROUTINES/METHODS | ||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||
| 47 | =head2 _next() | ||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||
| 49 | The underlying "next" that pulls the next line from the filehandle; | ||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||
| 51 | =cut | ||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||
| 53 | 11 | ▶ | sub _next { | ||||||||||||||||||||||||||
|
Subroutine
_next: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||
| 54 | 11 | my $self = shift; | |||||||||||||||||||||||||||
| 55 | 11 | my $fh = $self->{fh}; | |||||||||||||||||||||||||||
| 56 | 11 | ▶ | return if eof($fh); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 57 | 10 | local $/ = "\n"; | |||||||||||||||||||||||||||
| 58 | 10 | my $rec = <$fh>; | |||||||||||||||||||||||||||
| 59 | 10 | return $rec; | |||||||||||||||||||||||||||
| 60 | } | ||||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||
| 62 | |||||||||||||||||||||||||||||
| 63 | |||||||||||||||||||||||||||||
| 64 | =head2 decode(json) | ||||||||||||||||||||||||||||
| 65 | |||||||||||||||||||||||||||||
| 66 | =cut | ||||||||||||||||||||||||||||
| 67 | |||||||||||||||||||||||||||||
| 68 | 10 | ▶ | sub decode { | ||||||||||||||||||||||||||
|
Subroutine
decode: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 69 | 10 | my $self = shift; | |||||||||||||||||||||||||||
| 70 | 10 | my $str = shift; | |||||||||||||||||||||||||||
| 71 | 10 | return MARC::Record::MiJ->new($str); | |||||||||||||||||||||||||||
| 72 | } | ||||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||
| 74 | |||||||||||||||||||||||||||||
| 75 | =head2 encode | ||||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||
| 77 | =cut | ||||||||||||||||||||||||||||
| 78 | |||||||||||||||||||||||||||||
| 79 | 0 | ▶ | sub encode { | ||||||||||||||||||||||||||
|
Subroutine
encode: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||
| 80 | 0 | my $marc = shift; | |||||||||||||||||||||||||||
| 81 | 0 | ▶ | $marc = shift if (ref($marc)||$marc) =~ /^MARC::File/; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
ref $marc || $marc
MC/DC0%0/2
ref $marc || $marc
ref $marc
$marc
Truth table0%0/3
A || B
A= ref $marcB= $marc
| |||||||||||||||||||||||||||||
| 82 | 0 | return MARC::Record::MiJ->to_mij($marc); | |||||||||||||||||||||||||||
| 83 | } | ||||||||||||||||||||||||||||
| 84 | |||||||||||||||||||||||||||||
| 85 | |||||||||||||||||||||||||||||
| 86 | =head1 AUTHOR | ||||||||||||||||||||||||||||
| 87 | |||||||||||||||||||||||||||||
| 88 | Bill Dueber, C<< <dueberb at umich.edu> >> | ||||||||||||||||||||||||||||
| 89 | |||||||||||||||||||||||||||||
| 90 | =head1 BUGS | ||||||||||||||||||||||||||||
| 91 | |||||||||||||||||||||||||||||
| 92 | Please report any bugs or feature requests to C<bug-MARC-File-MiJ at rt.cpan.org>, or through | ||||||||||||||||||||||||||||
| 93 | the web interface at L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=MARC-File-MiJ>. I will be notified, and then you'll | ||||||||||||||||||||||||||||
| 94 | automatically be notified of progress on your bug as I make changes. | ||||||||||||||||||||||||||||
| 95 | |||||||||||||||||||||||||||||
| 96 | |||||||||||||||||||||||||||||
| 97 | |||||||||||||||||||||||||||||
| 98 | |||||||||||||||||||||||||||||
| 99 | =head1 SUPPORT | ||||||||||||||||||||||||||||
| 100 | |||||||||||||||||||||||||||||
| 101 | You can find documentation for this module with the perldoc command. | ||||||||||||||||||||||||||||
| 102 | |||||||||||||||||||||||||||||
| 103 | perldoc MARC::File::MiJ | ||||||||||||||||||||||||||||
| 104 | |||||||||||||||||||||||||||||
| 105 | |||||||||||||||||||||||||||||
| 106 | You can also look for information at: | ||||||||||||||||||||||||||||
| 107 | |||||||||||||||||||||||||||||
| 108 | =over 4 | ||||||||||||||||||||||||||||
| 109 | |||||||||||||||||||||||||||||
| 110 | =item * RT: CPAN's request tracker (report bugs here) | ||||||||||||||||||||||||||||
| 111 | |||||||||||||||||||||||||||||
| 112 | L<http://rt.cpan.org/NoAuth/Bugs.html?Dist=MARC-File-MiJ> | ||||||||||||||||||||||||||||
| 113 | |||||||||||||||||||||||||||||
| 114 | =item * AnnoCPAN: Annotated CPAN documentation | ||||||||||||||||||||||||||||
| 115 | |||||||||||||||||||||||||||||
| 116 | L<http://annocpan.org/dist/MARC-File-MiJ> | ||||||||||||||||||||||||||||
| 117 | |||||||||||||||||||||||||||||
| 118 | =item * CPAN Ratings | ||||||||||||||||||||||||||||
| 119 | |||||||||||||||||||||||||||||
| 120 | L<http://cpanratings.perl.org/d/MARC-File-MiJ> | ||||||||||||||||||||||||||||
| 121 | |||||||||||||||||||||||||||||
| 122 | =item * Search CPAN | ||||||||||||||||||||||||||||
| 123 | |||||||||||||||||||||||||||||
| 124 | L<http://search.cpan.org/dist/MARC-File-MiJ/> | ||||||||||||||||||||||||||||
| 125 | |||||||||||||||||||||||||||||
| 126 | =back | ||||||||||||||||||||||||||||
| 127 | |||||||||||||||||||||||||||||
| 128 | |||||||||||||||||||||||||||||
| 129 | =head1 ACKNOWLEDGEMENTS | ||||||||||||||||||||||||||||
| 130 | |||||||||||||||||||||||||||||
| 131 | |||||||||||||||||||||||||||||
| 132 | =head1 LICENSE AND COPYRIGHT | ||||||||||||||||||||||||||||
| 133 | |||||||||||||||||||||||||||||
| 134 | Copyright 2013 Bill Dueber. | ||||||||||||||||||||||||||||
| 135 | |||||||||||||||||||||||||||||
| 136 | This software is free software and may be distributed under the same | ||||||||||||||||||||||||||||
| 137 | terms as Perl itself. | ||||||||||||||||||||||||||||
| 138 | |||||||||||||||||||||||||||||
| 139 | |||||||||||||||||||||||||||||
| 140 | =cut | ||||||||||||||||||||||||||||
| 141 | |||||||||||||||||||||||||||||
| 142 | 1 | 1; # End of MARC::File::MiJ | |||||||||||||||||||||||||||