MARC::Moose::Lint::Processor - Processor to lint a biblio records file
version 1.0.22
A MARC::Moose::Lint::Checker to be used to validate biblio record.
The name of an ISO2709 file containing biblio records to control. When the processor object is created with this attribute, other attributes are automatically constructed: reader as MARC::Moose::Reader::File::Iso2709 object reading the file, writer_ok and writer_bad as MARC::Moose::Writer object with an ISO2709 formater writing to files named file.ok and file.bad, and fh_log as a IO::File, writing a text file named file.log.
reader
writer_ok
writer_bad
fh_log
A MARC::Moose::Formater which transform a MARC::Moose::Record into another MARC::Moose::Record. Using a cleaner, it's possible to clean biblio records before validating them.
A MARC::Moose::Reader object from which biblio records are read.
A MARC::Moose::Writer object in which valid biblio records are written.
A MARC::Moose::Writer object in which invalid biblio records are written.
A IO::File file handle which is used to write invalid biblio records with generated warnings.
package PeterCleaner; use Moose; extends 'MARC::Moose::Formater'; override 'format' => sub { my ($self, $record) = @_; for my $field (@{$record->fields}) { # clean content } return $record; }; package Main; my $processor = MARC::Moose::Lint::Processor->new( lint => MARC::Moose::Lint::Checker::RulesFile->new( file => 'unimarc.rules', file => 'biblio.mrc', cleaner => PeterCleaner->new(), verbose => 1, }; $processor->run();
The above script validates an ISO2709 file named biblio.mrc on a rules file named unimarc.rules. As a result, 3 files are created: (1) biblio.mrc.ok, an ISO2709 containing biblio records complying to the rules, (2) biblio.mrc.bad containing biblios violating the rules, and (3) biblio.mrc.log containing a textual representation of biblio records violating the rules + a description of violated rules.
A more specific construction is also possible:
my $lint => MARC::Moose::Lint::Checker::RulesFile->new( file => 'marc21.rules' ); my $processor = MARC::Moose::Lint::Processor->new( reader => MARC::Moose::Reader::File::Marcxml->new( file => 'biblio.xml', parser => MARC::Moose::Parser::Marcxml->new( lint => $lint ), writer_ok => MARC::Moose::Writer->new( formater => MARC::Moose::Formater::Marcxml->new(), fh => IO::File->new('ok.xml', '>:encoding(utf8') ), writer_bad => MARC::Moose::Writer->new( formater => MARC::Moose::Formater::Marcxml->new(), fh => IO::File->new('bad.xml', '>:encoding(utf8')) ), fh_log => IO::File->new('warnings.log', '>:encoding(utf8')), verbose => 1, ); $processor->run();
MARC::Moose
MARC::Moose::Lint::Checker
MARC::Moose::Lint::Checker::RulesFile
Frédéric Demians <f.demians@tamil.fr>
This software is copyright (c) 2015 by Frédéric Demians.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
To install MARC::Moose, copy and paste the appropriate command in to your terminal.
cpanm
cpanm MARC::Moose
CPAN shell
perl -MCPAN -e shell install MARC::Moose
For more information on module installation, please visit the detailed CPAN module installation guide.