NAME
Config::Path - Path-like config API with multiple file support and arbitrary backends from Config::Any
SYNOPSIS
use Config::Path;
my $conf = Config::Path->new(
files => [ 't/conf/configA.yml', 't/conf/configB.yml' ]
);
DESCRIPTION
Config::Path is a Yet Another Config module with a few twists that were desired for an internal project:
- Multiple files merged into a single, flat hash
- Path-based configuration value retrieval
- Clean, simple implementation
Multiple-File Merging
If any of your config files contain the same keys, the "right" file wins, using Hash::Merge's RIGHT_PRECEDENT setting. In other words, later file's keys will have precedence over those loaded earlier.
ATTRIBUTES
config_options
HashRef of options passed to Config::Any.
files
The list of files that will be parsed for this configuration.
METHODS
add_file ($file)
Adds the supplied filename to the list of files that will be loaded. Note that adding a file after you've already loaded a config will not change anything. You'll need to call reload
if you want to reread the configuration and include the new file.
clear_mask
Clear all values covered by mask
.
fetch ($path)
Get a value from the config file. As per the name of this module, fetch takes a path argument in the form of /foo/bar/baz
. This is effectively a shorthand way of expressing a series of hash keys. Whatever value is on the end of the keys will be returned. As such, fetch might return undef, scalar, arrayref, hashref or whatever you've stored in the config file.
my $foo = $config->fetch('/baz/bar/foo');
mask ('path/to/value', 'newvalue')
Override the specified key to the specified value. Note that this only changes the path's value in this instance. It does not change the config file. This is useful for tests. Note that exists
is used so setting a path to undef will not clear the mask. If you want to clear masks use clear_mask
.
reload
Rereads the config files specified in files
. Well, actually it just blows away the internal state of the config so that the next call will reload the configuration. Note that this also clears any mask
ing you've done.
AUTHOR
Cory G Watson, <gphat at cpan.org>
ACKNOWLEDGEMENTS
Jay Shirley
Mike Eldridge
COPYRIGHT & LICENSE
Copyright 2010 Magazines.com
This program is free software; you can redistribute it and/or modify it under the terms of either: the GNU General Public License as published by the Free Software Foundation; or the Artistic License.
See http://dev.perl.org/licenses/ for more information.
1 POD Error
The following errors were encountered while parsing the POD:
- Around line 36:
You forgot a '=back' before '=head2'