NAME
OpenFrame::Config - Simple OpenFrame configuration
SYNOPSIS
use OpenFrame::Config;
my $config = OpenFrame::Config->new();
my $value = $config->getKey('fred');
$config->setKey('rainy', 'yes');
DESCRIPTION
This module is a simple configuration interview for OpenFrame. All OpenFrame configuration will use this module.
There are two main methods of configuring OpenFrame: use Perl to create the configuration file using this module or edit an existing configuration file by hand.
Editing an existing file by hand is fairly painless due to the fact that configuration files are output using Data::Denter, which is a Perl data serializer that is optimized for human readability/editability, safe deserialization, and (eventually) speed.
The rest of this document will assume that you are intending to create the configuration file using Perl.
There are two special locations that OpenFrame::Config
will look to read a configuration file if you do not supply the constructor with any arguments. The first location is a file named ".openframe.conf" in the current directory, which is intended to be a local application configuration file. If that fails, the module look at the second location: "/etc/openframe.conf", which is intended to be a system-wide configuration file. If both fail then the configuration is empty by default.
When the Config object's writeConfig() is called (or the object goes out of scope), the object attempts to make its data persistent by writing to the two special locations above.
METHODS
new
This is the constructor.
my $config = OpenFrame::Config->new();
writeConfig
The configuration file will be automatically written out when the object goes out of scope. However, this can be forced by using the writeConfig method:
$config->writeConfig();
setKey
The setKey() method adds additional information to the configuration. It takes a key and a value:
$config->setKey('rainy', 'yes');
isKey
The isKey() method returns whether a key is part of the configuration, much like the exists() function for Perl hashes. It takes a key:
my $is_it_rainy = $config->isKey('rainy');
getKey
The getKey() method returns information from the configuration. It takes a key:
my $value = $config->getKey('rainy');
deleteKey
The deleteKey() method deletes information from the configuration. It takes a key:
$config->deleteKey('rainy');
sourceFile
The sourceFile() method returns the filename that the configuration is saved in.
my $filename = $config->sourceFile();
AUTHOR
James A. Duncan <jduncan@fotango.com>, Leon Brocard <leon@fotango.com>
COPYRIGHT
Copyright (C) 2001, Fotango Ltd.
This module is free software; you can redistribute it or modify it under the same terms as Perl itself.