SWISH::Prog::Doc - Document object class for passing to SWISH::Prog::Indexer
# subclass SWISH::Prog::Doc # and override filter() method package MyDoc; use base qw( SWISH::Prog::Doc ); sub filter { my $doc = shift; # alter url my $url = $doc->url; $url =~ s/my.foo.com/my.bar.org/; $doc->url( $url ); # alter content my $buf = $doc->content; $buf =~ s/foo/bar/gi; $doc->content( $buf ); } 1;
SWISH::Prog::Doc is the base class for Doc objects in the SWISH::Prog framework. Doc objects are created by SWISH::Prog::Aggregator classes and processed by SWISH::Prog::Indexer classes.
You can subclass SWISH::Prog::Doc and add a filter() method to alter the values of the Doc object before it is indexed.
All of the following methods may be overridden when subclassing this module, but the recommendation is to override only filter().
Instantiate Doc object.
All of the following params are also available as accessors/mutators.
Calls filter() on object.
Override this method to alter the values in the object prior to it being process()ed by the Indexer.
The default is to do nothing.
This method can also be set using the filter() callback in SWISH::Prog->new().
Return the Doc object rendered as a scalar string, ready to be indexed. This will include the proper headers. See SWISH::Prog::Headers.
NOTE: as_string() is also used if you use a Doc object as a string. Example:
print $doc->as_string; # one way print $doc; # same thing
http://swish-e.org/docs/
SWISH::Prog::Headers
Peter Karman, <perl@peknet.com>
Copyright 2008 by Peter Karman
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
To install SWISH::Prog, copy and paste the appropriate command in to your terminal.
cpanm
cpanm SWISH::Prog
CPAN shell
perl -MCPAN -e shell install SWISH::Prog
For more information on module installation, please visit the detailed CPAN module installation guide.