Why not adopt me?
This distribution is up for adoption!
If you're interested then please contact the PAUSE module admins via
email.
NAME
IRC::Indexer::Output - Turn trawler output into something useful
SYNOPSIS
use IRC::Indexer::Output::JSON;
# or: use IRC::Indexer::Output::YAML;
# or: use IRC::Indexer::Output::Dumper;
## Convert trawler output into JSON, for example:
my $output = IRC::Indexer::Output::JSON->new(
Input => $trawler->dump,
);
## Get output as a scalar:
print $output->dump;
## Write output to file:
$output->write($path);
DESCRIPTION
The IRC::Indexer::Output subclasses can convert IRC::Indexer::Bot::Trawl hashes into portable data formats.
You wouldn't normally use this module directly unless you are writing an output subclass; instead, you would use a subclass for a particular format, such as IRC::Indexer::Output::JSON.
METHODS
new
Create an output encoder; the reference to serialize must be specified:
my $out = IRC::Indexer::Output::JSON->new(
Input => $ref,
);
dump
Return the serialized output as a scalar.
my $json = $out->dump;
write
Write serialized output to a file path or an opened FH.
$out->write($path);
Will croak() on error.
WRITING SUBCLASSES
When writing an output subclass, you will need to override the methods dump() and write() to set a proper Output:
our @ISA = qw/IRC::Indexer::Output/;
sub dump {
my ($self) = @_;
my $input = $self->{Input};
## Serialize the $input hashref any way you like:
$self->{Output} = frobulate_my_input($input);
$self->SUPER::dump();
}
sub write {
my ($self, $path) = @_;
my $input = $self->{Input};
$self->{Output} = frobulate_my_input($input);
$self->SUPER::write($path);
}
AUTHOR
Jon Portnoy <avenj@cobaltirc.org>