OpenInteract2::Config::Base - Represents a server base configuration
# Sample base configuration website_dir /path/to/mysite config_type ini config_class OpenInteract2::Config::IniFile config_dir conf config_file server.ini package_dir pkg # Open an existing base config my $bc = OpenInteract2::Config::Base->new({ website_dir => '/path/to/mysite' }); my $bc = OpenInteract2::Config::Base->new({ filename => '/path/to/mysite/conf/base-alt.conf' }); # Create a new one and write it with the default filename my $bc = OpenInteract2::Config::Base->new; $bc->website_dir( '/path/to/mysite' ); $bc->config_type( 'ini' ); $bc->config_class( 'OpenInteract2::Config::IniFile' ); $bc->config_dir( 'conf' ); $bc->config_file( 'server.ini' ); $bc->package_dir( 'pkg' ); $bc->write;
A base configuration enables you to easily bootstrap an OpenInteract server configuration with just a little information.
new( [ \%params ] )
Creates a new base config object. You can initialize it with as many parameters as you like if you are creating one from scratch.
You can also pass in one of:
And the constructor will read values from filename or the filename returned by create_filename() with website_dir. The constructor will also set the filename property to the file from which the values were read.
filename
create_filename()
website_dir
Returns: A OpenInteract2::Config::Base object.
OpenInteract2::Config::Base
read_config( $filename )
Reads configuration values from $filename and returns the configured key/value pairs. When reading in the file we sskip all blank lines as well as lines beginning with a '#' for comments. Extra space is stripped from the beginning and ending of all keys and values.
$filename
Returns: Hashref of config values from $filename.
create_website_filename( $website_directory )
Creates a typicaly configuration filename given $website_directory. This is:
$website_directory
$website_directory/BASE_CONF_DIR/BASE_CONF_FILE
where BASE_CONF_DIR and BASE_CONF_FILE are from OpenInteract2::Constants.
BASE_CONF_DIR
BASE_CONF_FILE
An exception is thrown if $directory is not provided. We do not check whether $directory is a valid directory.
$directory
Returns: a potential filename for a base config object
create_filename( $directory )
Creates a typical configuration filename given $directory. This is:
$directory/BASE_CONF_FILE
where BASE_CONF_FILE is from OpenInteract2::Constants.
initialize( \%params )
You will probably never call this as it is only used from the constructor.
Returns: a OpenInteract2::Config::Base object with relevant properties from \%params set.
\%params
clean_dir( $property_name )
Remove the trailing '/' from the directory specified by $property_name. Sets the property in the object and returns the cleaned directory.
$property_name
Example:
$bc->clean_dir( 'config_dir' ); $bc->clean_dir( 'website_dir' );
Returns: the cleaned directory.
get_server_config_file()
Puts together the properties 'website_dir', 'config_dir' and 'config_file' to create a fully qualified filename.
Returns: full filename for the server config.
save_config()
Writes the configured values from the object to a file. If you do not set a filename before calling this the method will create one for you using create_filename() and the value from the website_dir property.
If you do not have all the properties defined the method will throw an exception.
Returns: the filename to which the configuration was written.
website_dir: Root directory of the website
config_type: Type of configuration site is using
config_class: Class used to read server configuration
config_dir: Directory where configuration is kept, relative to website_dir
config_file: Name of configuration file in config_dir
config_dir
package_dir: Directory where packages are kept, relative to website_dir.
filename: Location of base_configuration file. Not written out to the base configuration file.
None known.
Nothing known.
Class::Accessor
Copyright (c) 2001-2004 Chris Winters. All rights reserved.
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
Chris Winters <chris@cwinters.com>
To install OpenInteract2::URL, copy and paste the appropriate command in to your terminal.
cpanm
cpanm OpenInteract2::URL
CPAN shell
perl -MCPAN -e shell install OpenInteract2::URL
For more information on module installation, please visit the detailed CPAN module installation guide.