Biblio...cessor(3pm)

πŸ’– Biblio::COUNTER::Processor β€” the superclass era πŸ’–

okay bestie, sit down, hydrate, and let me tell you about Biblio::COUNTER::Processor, a Perl module from the User Contributed Perl Documentation collection 🫢


✨ NAME ✨

Biblio::COUNTER::Processor β€” it's the superclass for Biblio::COUNTER processors. literally the blueprint. the mother of all processors. the blueprint that does nothing on purpose πŸ’…


🌸 SYNOPSIS 🌸

so here's how you'd actually use it:

# Use
use Biblio::COUNTER::Processor;
$processor = Biblio::COUNTER::Processor->new;
$processor->ignore(@events);
$report = $processor->run;

and here's how you'd subclass it, which is kind of the whole point:

# Subclass
use MyProcessor;
@MyProcessor::ISA = qw(Biblio::COUNTER::Processor);
# Event handlers
sub begin_report {
    my ($self, $report) = @_;
    # etc.
}
sub count {
    my ($self, $report, $scope, $field, $period, $val) = @_;
    # etc.
}
# etc.

look at those handler signatures. iconic. πŸŽ€


πŸ¦‹ DESCRIPTION πŸ¦‹

Biblio::COUNTER::Processor is an inheritable class, and what it gives you is an intermediate interface to Biblio::COUNTER.

here's the tea though: when you use it on its own, it does nothing. absolutely nothing. zero. it's giving "I'm just here to be a parent class." 😭 subclasses are the ones who have to define handlers for the various events β€” stuff like begin_report or count β€” that get triggered while a report is being processed.

Event-handling methods, if they're defined, get invoked with the exact same arguments that are documented in Biblio::COUNTER, with one lil twist: an additional argument gets prepended β€” that's the instance of the Biblio::COUNTER::Processor subclass itself. so your $self comes first, always, no cap.

and if you want a class that actually does something when events fire? go look at Biblio::COUNTER::Processor::Simple. that one's the overachiever. πŸ’–


πŸ’… METHODS πŸ’…

new

$processor = Biblio::COUNTER::Processor->new;

creates a brand new processor. that's it. that's the whole job. slay. ✨

run($file)

$report = $processor->run($what);

processes the given report.

now, $what is flexible like that β€” it can be any of these:

  • a file handle
  • the name of a file
  • an instance of (a subclass of) Biblio::COUNTER::Report

a Biblio::COUNTER::Report object gets instantiated and its process method gets invoked. and every single time an event is triggered, a method with the event's name β€” like begin_record or cant_fix β€” gets invoked if it is defined.

and since this class doesn't define any of those methods, the default behavior when an event is triggered is... to do nothing. 😭 literally the "I'm not gonna say anything" meme.

ignore(@events)

$processor->ignore(qw/line input output/);

tells the processor which events to ignore. the various events are all documented in Biblio::COUNTER, so go read that if you need the full list. bestie behavior honestly. πŸ“š


🌈 INHERITANCE 🌈

Biblio::COUNTER::Processor is designed to be inheritable. in fact β€” and I cannot stress this enough β€” it doesn't do anything on its own.

unless, of course, you count ignoring events as doing something. which... fair. that's a whole personality trait honestly. πŸ’€


πŸ‘‘ BUGS πŸ‘‘

there are no known bugs. none. zero. the vibe check passed. ✨

if you do find one though, please report bugs to the author via e-mail (see below, bestie, the info's right there). 🫢


πŸŽ€ AUTHOR πŸŽ€

Paul Hoffman (nkuitse AT cpan DOT org)


Copyright 2008 Paul M. Hoffman.

This is free software, and is made available under the same terms as Perl itself. πŸ’–


⭐ SEE ALSO ⭐

  • Biblio::COUNTER
  • Biblio::COUNTER::Report
  • Biblio::COUNTER::Report::Processor::Simple

and that's the whole page, bestie!! πŸ¦‹ this was perl v5.36.0, dated 2023-02-04, brought to you by the fine folks behind the User Contributed Perl Documentation. now go forth and subclass responsibly. periodt. πŸ’…βœ¨

πŸ“¦ where this page comes from