NAME
SWISH::Prog::Config - read & write Swish-e config files
SYNOPSIS
use SWISH::Prog::Config;
my $config = SWISH::Prog::Config->new;
DESCRIPTION
The SWISH::Prog::Config class is intended to be accessed via SWISH::Prog new().
See the Swish-e documentation for a list of configuration parameters. Each parameter has an accessor/mutator method as part of the Config object. Some preliminary compatability is offered for Swish::Config with XML format config files.
NOTE: Every config parameter can take either a scalar or an array ref as a value. In addition, you may append config values to any existing values by passing an additional true argument. The return value of any 'get' is always an array ref.
Example:
$config->MetaNameAlias( ['foo bar', 'one two', 'red yellow'] );
$config->MetaNameAlias( 'green blue', 1 );
print join("\n", @{ $config->MetaNameAlias }), " \n";
# would print:
# foo bar
# one two
# red yellow
# green blue
METHODS
new( params )
Instatiate a new Config object. Takes a hash of key/value pairs, where each key may be a Swish-e configuration parameter.
Example:
my $config = SWISH::Prog::Config->new( DefaultContents => 'HTML*' );
print "DefaultContents is ", $config->DefaultContents, "\n";
read2( path/file )
Reads version 2 compatible config file and stores in current object. Returns parsed config file as a hashref or undef on failure to parse.
Example:
use SWISH::Prog::Config;
my $config = SWISH::Prog::Config->new();
my $parsed = $config->read2( 'my/file.cfg' );
# should print same thing
print $config->WordCharacters->[0], "\n";
print $parsed->{WordCharacters}, "\n";
write2( path/file )
Writes version 2 compatible config file.
If path/file is omitted, a temp file will be written using File::Temp.
Returns full path to file.
Full path is also available via file() method.
file
Returns name of the file written by write2().
ver2_to_xml( file )
Utility method for converting Swish-e version 2 style config files to SWISH::Config XML style.
Converts file to XML format and returns as XML string.
NOTE: This API is liable to change as SWISH::Config is developed.
my $xmlconf = $config->ver2_to_xml( 'my/file.config' );
TODO
IgnoreTotalWordCountWhenRanking defaults to 0 which is not the default in Swish-e. This is to make the RankScheme feature work by default. Really, the default should be 0 in Swish-e itself.
SEE ALSO
SWISH::Prog, SWISH::Parser
AUTHOR
Peter Karman, <perl@peknet.com>
COPYRIGHT AND LICENSE
Copyright 2006 by Peter Karman
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.