NAME

Config::Context::ConfigGeneral - Use Config::General (Apache-style) config files with Config::Context

SYNOPSIS

use Config::Context;

my $config_text = '

    <Location /users>
        title = "User Area"
    </Location>

    <LocationMatch \.*(jpg|gif|png)$>
        image_file = 1
    </LocationMatch>

';

my $conf = Config::Context->new(
    string        => $config_text,
    driver        => 'ConfigGeneral',
    match_sections => [
        {
            name          => 'Location',
            match_type    => 'path',
        },
        {
            name          => 'LocationMatch',
            match_type    => 'regex',
        },
    ],
);

my %config = $conf->context('/users/~mary/index.html');

use Data::Dumper;
print Dumper(\%config);
--------
$VAR1 = {
    'title'         => 'User Area',
    'image_file'    => undef,
};

my %config = $conf->getall_matching('/users/~biff/images/flaming_logo.gif');
print Dumper(\%config);
--------
$VAR1 = {
    'title'         => 'User Area',
    'image_file'    => 1,
};

DESCRIPTION

This module uses Config::General to parse Apache-style config files for Config::Context. See the Config::Context docs for more information.

DEFAULT OPTIONS

In addition to the options normally enabled by Config::Scoped, the following options are turned on by default:

-MergeDuplicateBlocks  => 1
-MergeDuplicateOptions => 1
-IncludeRelative       => 1

You can change this behaviour by passing a different value to driver_params to new:

my $conf = Config::Context->new(
    driver => 'ConfigGeneral',
    driver_options => {
       ConfigGeneral = > {
           -MergeDuplicateBlocks  => 0,
       },
    },
);

CONSTRUCTOR

new(...)

my $driver = Config::Context::ConfigGeneral->new(
    file             => $config_file,
    lower_case_names => 1,  # optional
    options          => {
        # ...
    }
);

or:

my $driver = Config::Context::ConfigGeneral->new(
    string           => $config_string,
    lower_case_names => 1,  # optional
    options          => {
        # ...
    }
);

Returns a new driver object, using the provided options.

METHODS

parse()

Returns the data structure for the parsed config.

files()

Returns a list of all the config files read, including any config files included in the main file.

config_modules

Returns the modules used to parse the config. In this case: Config::General

CAVEATS

Don't quote block names

Instead of:

<Location '/foo'>
</Location>

Use:

<Location /foo>
</Location>

SEE ALSO

Config::Context
CGI::Application::Plugin::Config::Context
Config::General

COPYRIGHT & LICENSE

Copyright 2004-2005 Michael Graham, All Rights Reserved.

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