Sherzod Ruzmetov > Config-Simple-App-0.01 > Config::Simple::App

Download:
Config-Simple-App-0.01.tar.gz

Dependencies

Annotate this POD

CPAN RT

Open  0
Report a bug
Module Version: 0.01   Source  

NAME ^

Config::Simple::App - Perl extension for managing application's configuration settings

SYNOPSIS ^

    # inside App/Config.pm
    package App::Config;
    use base qw( Config::Simple::App );

    sub _init {
        my $self = shift;

        $self->define("AppPath", "/home/sherzodr/public_html/author/");
        $self->define("AppURL", "http://author.handalak.com/");
        $self->define("CGIPath", $self->AppURL . "cgi-bin/" );
        $self->define("DBDriver");
        $self->define("DBName");
        $self->define("DBUser");
        $self->define("DBPassword");
        $self->define("DBPath", $self->AppPath . "db/");

    }

    1;

    __END__;


    # in your application:
    $config = new App::Config("config.ini");
    print $config->AppPath();
    # etc..

ABSTRACT ^

    Config::Simple::App is meant to be sub classed by applications' 
    configuration manager class. Relies on Config::Simple to parse
    configuration files into configuration manager instance.

DESCRIPTION ^

One can, of course, use Config::Simple to manage their applications' configuration files. Although perfect for reading and writing configuration files of various formats, Config::Simple does not provide obvious ways for validating configuration file's attributes and for assigning default attribute values.

Is that such a big deal? Consider the following:

Config::Simple::App attempts to deliver all the above features to your application

EXPORT

None.

PROGRAMMING STYLE ^

Config::Simple::App is not meant to be used directly, but through sub classing.

First step in creating a configuration manager class is to subclass Config::Simple::App.

    package App::ConfigManager;
    use base qw( Config::Simple::App );

Config::Simple::App provides new() and define() methods to your configuration class. The next step is to define an _init() routine that gets called by new() after configuration file has been processed. You need to call define() for each attribute that a configuration file can have that is considered valid. This does not mean all those attributes must be present, but can be present.

    sub _init {
        my $self = shift;

        $self->define("Path");
        $self->define("TemplatePath", $self->Path . 'tmpl');
    }

METHODS ^

new($config_file)
define($attribute)
define($attribute, $default_value)

SEE ALSO ^

Config::Simple

AUTHOR ^

Sherzod B. Ruzmetov <sherzodr@localdomain>

COPYRIGHT AND LICENSE ^

Copyright 2005 by Sherzod B. Ruzmetov

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.