diff --git a/lib/Catmandu/Exporter/MAB2.pm b/lib/Catmandu/Exporter/MAB2.pm index 0498b1a..51c7d85 100644 --- a/lib/Catmandu/Exporter/MAB2.pm +++ b/lib/Catmandu/Exporter/MAB2.pm @@ -1,7 +1,7 @@ package Catmandu::Exporter::MAB2; -# ABSTRACT: Package that exports MAB2 data -# VERSION +#ABSTRACT: Package that exports MAB2 data +#VERSION use Catmandu::Sane; use MAB2::Writer::Disk; @@ -116,9 +116,24 @@ Add record to exporter. Close collection (optional) and filehandle. -=head1 SEE ALSO +=head1 CONFIGURATION -L, L. +In addition to the configuration provided by L (C, +C, etc.) the importer can be configured with the following parameters: + +=over + +=item type + +MAB2 syntax variant. See L. + +=item xml_declaration + +Write XML declaration. Set to 0 or 1. Default: 0. Optional. + +=item collection + +Wrap records in collection element (). Set to 0 or 1. Default: 0. Optional. =cut diff --git a/lib/Catmandu/Fix/mab_map.pm b/lib/Catmandu/Fix/mab_map.pm index 78a4f70..d978ea0 100644 --- a/lib/Catmandu/Fix/mab_map.pm +++ b/lib/Catmandu/Fix/mab_map.pm @@ -1,7 +1,7 @@ package Catmandu::Fix::mab_map; -# ABSTRACT: copy mab values of one field to a new field -# VERSION +#ABSTRACT: copy mab values of one field to a new field +#VERSION use Catmandu::Sane; use Catmandu::Util qw(:is :data); @@ -210,8 +210,4 @@ sub mab_subfield { # Do the same examples now with the fields in 'record2' mab_map('245','my.title', -record => 'record2'); -=head1 SEE ALSO - -L, L; - =cut diff --git a/lib/Catmandu/Importer/MAB2.pm b/lib/Catmandu/Importer/MAB2.pm index d57a746..d77312c 100644 --- a/lib/Catmandu/Importer/MAB2.pm +++ b/lib/Catmandu/Importer/MAB2.pm @@ -1,7 +1,7 @@ package Catmandu::Importer::MAB2; -# ABSTRACT: Package that imports MAB2 data -# VERSION +#ABSTRACT: Package that imports MAB2 data +#VERSION use Catmandu::Sane; use Moo; @@ -57,34 +57,16 @@ sub generator { use Catmandu::Importer::MAB2; - my $importer = Catmandu::Importer::MAB2->new(file => "./t/mab2.dat", type=> "RAW"); + my $importer = Catmandu::Importer::MAB2->new(file => "./t/mab2.dat", type=> "raw"); my $n = $importer->each(sub { my $hashref = $_[0]; # ... }); -=head1 Arguments +To convert between MAB2 syntax variants with the L command line client: -=over - -=item C - -Path to file with MAB2 records. - -=item C - -Open filehandle for file with MAB2 records. - -=item C - -Specify MAB2 field tag to get record identifier from. Default: 001. Optional. - -=item C - -Specify type of MAB2 records: Disk (Diskette), RAW (Band), XML. Default: RAW. Optional. - -=back + catmandu convert MAB2 --type raw to MAB2 --type xml < mab2.dat =head1 MAB2 @@ -113,22 +95,23 @@ identifier of the record) and 'record' containing an ARRAY of ARRAYs for every f =head1 METHODS -=head2 new(file => $filename | fh => $filehandle [,type => $type, id => $field_tag]) +This module inherits all methods of L and by this +L. -Create a new MAB2 importer for $filename. Use STDIN when no filename is given. +=head1 CONFIGURATION -=head2 count +In addition to the configuration provided by L (C, +C, etc.) the importer can be configured with the following parameters: -=head2 each(&callback) - -=head2 ... +=over -Every Catmandu::Importer is a Catmandu::Iterable all its methods are inherited. The -Catmandu::Importer::MAB methods are not idempotent: MAB feeds can only be read once. +=item type -=head1 SEE ALSO +Describes the MAB2 syntax variant. Supported values (case ignored) include the +default value C for MABxml, C for human-readable MAB2 serialization +and C or C for normalized MAB2. -L, L; +=back =cut diff --git a/lib/Catmandu/Importer/SRU/Parser/mabxml.pm b/lib/Catmandu/Importer/SRU/Parser/mabxml.pm index 1fc8ba5..f6840c6 100644 --- a/lib/Catmandu/Importer/SRU/Parser/mabxml.pm +++ b/lib/Catmandu/Importer/SRU/Parser/mabxml.pm @@ -1,7 +1,7 @@ package Catmandu::Importer::SRU::Parser::mabxml; -# ABSTRACT: Package transforms SRU responses into Catmandu MAB2 -# VERSION +#ABSTRACT: Package transforms SRU responses into Catmandu MAB2 +#VERSION use Moo; use MAB2::Parser::XML; @@ -12,25 +12,24 @@ sub parse { my $xml = $record->{recordData}; my $parser = MAB2::Parser::XML->new( $xml ); - my $record_hash = $parser->next(); - - return $record_hash; + return $parser->next(); } =head1 SYNOPSIS -my %attrs = ( - base => 'http://sru.gbv.de/gvk', - query => '1940-5758', - recordSchema => 'mabxml' , - parser => 'mabxml' , -); + my %attrs = ( + base => 'http://sru.gbv.de/gvk', + query => '1940-5758', + recordSchema => 'mabxml' , + parser => 'mabxml' , + ); -my $importer = Catmandu::Importer::SRU->new(%attrs); + my $importer = Catmandu::Importer::SRU->new(%attrs); =head1 DESCRIPTION -Each mabxml response will be transformed into an format as defined by L +Each mabxml response will be transformed into the format defined by +L =cut diff --git a/lib/Catmandu/MAB2.pm b/lib/Catmandu/MAB2.pm index 589a265..bc823e4 100644 --- a/lib/Catmandu/MAB2.pm +++ b/lib/Catmandu/MAB2.pm @@ -1,14 +1,18 @@ package Catmandu::MAB2; -# ABSTRACT: Catmandu modules for working with MAB2 data. -# VERSION +#ABSTRACT: Catmandu modules for working with MAB2 data. +#VERSION use strict; use warnings; -=head1 CATMANDU MODULES +=head1 DESCRIPTION + +Catmandu::MAB2 provides methods to work with MAB2 data within the L +framework. See L and L for an +introduction into Catmandu. -Catmandu modules for parsing, fixing and writing MAB2 data. +=head1 CATMANDU MODULES =over @@ -16,13 +20,15 @@ Catmandu modules for parsing, fixing and writing MAB2 data. =item * L +=item * L + =item * L =back =head1 INTERNAL MODULES -Parser and writer for MAB2 data. These modules could also be used without Catmandu. +Parser and writer for MAB2 data. =over @@ -42,23 +48,6 @@ Parser and writer for MAB2 data. These modules could also be used without Catman =back -=head1 SUPPORT - -You can find documentation for this distribution with the perldoc command. - - perldoc Catmandu::Importer::MAB2 - perldoc Catmandu::Exporter::MAB2 - perldoc Catmandu::Fix::mab_map - -You can also look for information at: - - Catmandu - https://metacpan.org/module/Catmandu::Introduction - https://metacpan.org/search?q=Catmandu - - LibreCat - http://librecat.org/tutorial/index.html - =cut 1; # End of Catmandu::MAB2 diff --git a/lib/MAB2/Parser/Disk.pm b/lib/MAB2/Parser/Disk.pm index 9b78055..d458348 100644 --- a/lib/MAB2/Parser/Disk.pm +++ b/lib/MAB2/Parser/Disk.pm @@ -1,7 +1,7 @@ package MAB2::Parser::Disk; -# ABSTRACT: MAB2 Diskette format parser -# VERSION +#ABSTRACT: MAB2 Diskette format parser +#VERSION use strict; use warnings; diff --git a/lib/MAB2/Parser/RAW.pm b/lib/MAB2/Parser/RAW.pm index 648f3d1..7280828 100644 --- a/lib/MAB2/Parser/RAW.pm +++ b/lib/MAB2/Parser/RAW.pm @@ -1,7 +1,7 @@ package MAB2::Parser::RAW; -# ABSTRACT: MAB2 RAW format parser -# VERSION +#ABSTRACT: MAB2 RAW format parser +#VERSION use strict; use warnings; diff --git a/lib/MAB2/Parser/XML.pm b/lib/MAB2/Parser/XML.pm index d00c6cb..e443bfc 100644 --- a/lib/MAB2/Parser/XML.pm +++ b/lib/MAB2/Parser/XML.pm @@ -1,7 +1,7 @@ package MAB2::Parser::XML; -# ABSTRACT: MAB2 XML parser -# VERSION +#ABSTRACT: MAB2 XML parser +#VERSION use strict; use warnings; @@ -12,9 +12,6 @@ use XML::LibXML::Reader; L is a parser for MAB2 XML records. -L expects UTF-8 encoded files as input. Otherwise provide a -filehande with a specified I/O layer. - use MAB2::Parser::XML; my $parser = MAB2::Parser::XML->new( $filename ); diff --git a/lib/MAB2/Writer/Disk.pm b/lib/MAB2/Writer/Disk.pm index f092d68..bbd4c6e 100644 --- a/lib/MAB2/Writer/Disk.pm +++ b/lib/MAB2/Writer/Disk.pm @@ -1,7 +1,7 @@ package MAB2::Writer::Disk; -# ABSTRACT: MAB2 Diskette format serializer -# VERSION +#ABSTRACT: MAB2 Diskette format serializer +#VERSION use strict; use charnames ':full'; diff --git a/lib/MAB2/Writer/Handle.pm b/lib/MAB2/Writer/Handle.pm index 481710f..d0703ae 100644 --- a/lib/MAB2/Writer/Handle.pm +++ b/lib/MAB2/Writer/Handle.pm @@ -1,7 +1,7 @@ package MAB2::Writer::Handle; -# ABSTRACT: Utility class for common MAB2::Writer arguments and methods. -# VERSION +#ABSTRACT: Utility class for common MAB2::Writer arguments and methods. +#VERSION use strict; use Moo::Role; diff --git a/lib/MAB2/Writer/RAW.pm b/lib/MAB2/Writer/RAW.pm index 21d8fc3..aa2956a 100644 --- a/lib/MAB2/Writer/RAW.pm +++ b/lib/MAB2/Writer/RAW.pm @@ -1,7 +1,7 @@ package MAB2::Writer::RAW; -# ABSTRACT: MAB2 RAW format serializer -# VERSION +#ABSTRACT: MAB2 RAW format serializer +#VERSION use strict; use Moo; diff --git a/lib/MAB2/Writer/XML.pm b/lib/MAB2/Writer/XML.pm index a61cbf6..a3a5748 100644 --- a/lib/MAB2/Writer/XML.pm +++ b/lib/MAB2/Writer/XML.pm @@ -1,7 +1,7 @@ package MAB2::Writer::XML; -# ABSTRACT: MAB2 XML format serializer -# VERSION +#ABSTRACT: MAB2 XML format serializer +#VERSION use strict; use Moo;