Michael Peters > Smolder-1.40 > Smolder::Conf

Download:
Smolder-1.40.tar.gz

Dependencies

Annotate this POD

CPAN RT

New  7
Open  3
View Bugs
Report a bug
Source  

NAME ^

Smolder::Conf - Smolder configuration module

SYNOPSIS ^

    # all configuration directives are available as exported subs
    use Smolder::Conf qw(Secret Port);
    $secret = Secret;

    # you can also call get() in Smolder::Conf directly
    $port = Smolder::Conf->get("Port");

    # or you can access them as methods in the Smolder::Conf module
    $port = Smolder::Conf->Port;

    # give Smolder::Conf some values to override the defaults
    Smolder::Conf->init(
        Secret   => '1Adxd23023s',
        Port     => 80,
        HostName => 'smolder.myorg.com',
        LogFile  => '/path/to/logs',
    );

    # pull the conf values from a file
    Smolder::Conf->init_from_file('/path/to/conf/file');

DESCRIPTION ^

This module provides access to the configuration settings in smolder.conf. Smolder tries to have reasonable defaults but they can be overridden when needed.

METHODS ^

init

Override the configuration defaults by providing named-value pairs:

    Smolder::Conf->init(
        Secret   => '1Adxd23023s',
        Port     => 80,
        HostName => 'smolder.myorg.com',
        LogFile  => '/path/to/logs',
    );

init_from_file

Override the configuration defaults by providing a file. Config files are simple lists of name-values pairs. One pair per-line and each name/value is separated by whitespace:

    HostName    smolder.test
    DataDir     /var/lib/smolder/
    Port        80
    FromAddress smolder@smolder.test
    TemplateDir /var/share/smolder/templates
    HtdocsDir   /var/share/smolder/htdocs
    SQLDir      /var/share/smolder/sql

get

Given a directive name, returns the value (which may be a list) of a configuration directive. Directive names are case-insensitive.

    $value = Smolder::Conf->get('DirectiveName');

test_data_dir

The directory path for test data directory for this copy of Smolder

ACCESSOR METHODS ^

All configuration directives can be accessed as methods themselves.

    my $port = Smolder::Conf->port();

Gets the value of a directive using an autoloaded method. Directive names are case-insensitive.

EXPORTING DIRECTIVES ^

Each configuration directive can also be accessed as an exported subroutine.

    use Smolder::Conf qw(port FromAddress);
    ...
    my $port = port();
    my $from = FromAddress();

Directive names are case-insensitive. Gets the value of a variable using an exported, autoloaded method. Case-insensitive.