The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

MARC::Moose::Lint::Processor - Processor to lint a biblio records file

VERSION

version 1.0.36

ATTRIBUTES

lint

A MARC::Moose::Lint::Checker to be used to validate biblio record.

file

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.

cleaner

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.

reader

A MARC::Moose::Reader object from which biblio records are read.

writer_ok

A MARC::Moose::Writer object in which valid biblio records are written.

writer_bad

A MARC::Moose::Writer object in which invalid biblio records are written.

writer_bad

A IO::File file handle which is used to write invalid biblio records with generated warnings.

SYNOPSYS

 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();

SEE ALSO

AUTHOR

Frédéric Demians <f.demians@tamil.fr>

COPYRIGHT AND LICENSE

This software is copyright (c) 2018 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.