Skip to content

Commit

Permalink
documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
jorol committed Apr 5, 2014
1 parent bd65b9e commit f725383
Show file tree
Hide file tree
Showing 12 changed files with 74 additions and 95 deletions.
23 changes: 19 additions & 4 deletions lib/Catmandu/Exporter/MAB2.pm
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -116,9 +116,24 @@ Add record to exporter.
Close collection (optional) and filehandle.
=head1 SEE ALSO
=head1 CONFIGURATION
L<Catmandu::Exporter>, L<Catmandu::Iterable>.
In addition to the configuration provided by L<Catmandu::Exporter> (C<file>,
C<fh>, etc.) the importer can be configured with the following parameters:
=over
=item type
MAB2 syntax variant. See L<Catmandu::Importer::MAB2>.
=item xml_declaration
Write XML declaration. Set to 0 or 1. Default: 0. Optional.
=item collection
Wrap records in collection element (<datei>). Set to 0 or 1. Default: 0. Optional.
=cut

Expand Down
8 changes: 2 additions & 6 deletions lib/Catmandu/Fix/mab_map.pm
Original file line number Diff line number Diff line change
@@ -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);
Expand Down Expand Up @@ -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<Catmandu::Fix>, L<Catmandu::Introduction>;
=cut
49 changes: 16 additions & 33 deletions lib/Catmandu/Importer/MAB2.pm
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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<catmandu> command line client:
=over
=item C<file>
Path to file with MAB2 records.
=item C<fh>
Open filehandle for file with MAB2 records.
=item C<id>
Specify MAB2 field tag to get record identifier from. Default: 001. Optional.
=item C<type>
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
Expand Down Expand Up @@ -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<Catmandu::Importer> and by this
L<Catmandu::Iterable>.
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<Catmandu::Importer> (C<file>,
C<fh>, 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<xml> for MABxml, C<disk> for human-readable MAB2 serialization
and C<plus> or C<raw> for normalized MAB2.
L<Catmandu::Importer>, L<Catmandu::Iterable>;
=back
=cut

Expand Down
25 changes: 12 additions & 13 deletions lib/Catmandu/Importer/SRU/Parser/mabxml.pm
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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<Catmandu::Importer::PICA>
Each mabxml response will be transformed into the format defined by
L<Catmandu::Importer::PICA>
=cut

Expand Down
33 changes: 11 additions & 22 deletions lib/Catmandu/MAB2.pm
Original file line number Diff line number Diff line change
@@ -1,28 +1,34 @@
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<Catmandu>
framework. See L<Catmandu::Introduction> and L<http://librecat.org/> for an
introduction into Catmandu.
Catmandu modules for parsing, fixing and writing MAB2 data.
=head1 CATMANDU MODULES
=over
=item * L<Catmandu::Importer::MAB2>
=item * L<Catmandu::Exporter::MAB2>
=item * L<Catmandu::Importer::SRU::Parser::mabxml>
=item * L<Catmandu::Fix::mab_map>
=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
Expand All @@ -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
4 changes: 2 additions & 2 deletions lib/MAB2/Parser/Disk.pm
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package MAB2::Parser::Disk;

# ABSTRACT: MAB2 Diskette format parser
# VERSION
#ABSTRACT: MAB2 Diskette format parser
#VERSION

use strict;
use warnings;
Expand Down
4 changes: 2 additions & 2 deletions lib/MAB2/Parser/RAW.pm
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package MAB2::Parser::RAW;

# ABSTRACT: MAB2 RAW format parser
# VERSION
#ABSTRACT: MAB2 RAW format parser
#VERSION

use strict;
use warnings;
Expand Down
7 changes: 2 additions & 5 deletions lib/MAB2/Parser/XML.pm
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package MAB2::Parser::XML;

# ABSTRACT: MAB2 XML parser
# VERSION
#ABSTRACT: MAB2 XML parser
#VERSION

use strict;
use warnings;
Expand All @@ -12,9 +12,6 @@ use XML::LibXML::Reader;
L<MAB2::Parser::XML> is a parser for MAB2 XML records.
L<MAB2::Parser::XML> 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 );
Expand Down
4 changes: 2 additions & 2 deletions lib/MAB2/Writer/Disk.pm
Original file line number Diff line number Diff line change
@@ -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';
Expand Down
4 changes: 2 additions & 2 deletions lib/MAB2/Writer/Handle.pm
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
4 changes: 2 additions & 2 deletions lib/MAB2/Writer/RAW.pm
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package MAB2::Writer::RAW;

# ABSTRACT: MAB2 RAW format serializer
# VERSION
#ABSTRACT: MAB2 RAW format serializer
#VERSION

use strict;
use Moo;
Expand Down
4 changes: 2 additions & 2 deletions lib/MAB2/Writer/XML.pm
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package MAB2::Writer::XML;

# ABSTRACT: MAB2 XML format serializer
# VERSION
#ABSTRACT: MAB2 XML format serializer
#VERSION

use strict;
use Moo;
Expand Down

0 comments on commit f725383

Please sign in to comment.