Config::ZOMG(3pm) | User Contributed Perl Documentation | Config::ZOMG(3pm) |
Config::ZOMG - Yet Another Catalyst::Plugin::ConfigLoader-style layer over Config::Any
version 1.000000
"Config::ZOMG" is a fork of Config::JFDI. It removes a couple of unusual features and passes the same tests three times faster than Config::JFDI.
"Config::ZOMG" is an implementation of Catalyst::Plugin::ConfigLoader that exists outside of Catalyst.
"Config::ZOMG" will scan a directory for files matching a certain name. If such a file is found which also matches an extension that Config::Any can read, then the configuration from that file will be loaded.
"Config::ZOMG" will also look for special files that end with a "_local" suffix. Files with this special suffix will take precedence over any other existing configuration file, if any. The precedence takes place by merging the local configuration with the "standard" configuration via Hash::Merge::Simple.
Finally you can override/modify the path search from outside your application, by setting the "${NAME}_CONFIG" variable outside your application (where $NAME is the uppercase version of what you passed to Config::ZOMG->new).
use Config::ZOMG; my $config = Config::ZOMG->new( name => 'my_application', path => 'path/to/my/application', ); my $config_hash = $config->load;
This will look for something like (depending on what Config::Any will find):
path/to/my/application/my_application_local.{yml,yaml,cnf,conf,jsn,json,...}
and
path/to/my/application/my_application.{yml,yaml,cnf,conf,jsn,json,...}
... and load the found configuration information appropiately, with "_local" taking precedence.
You can also specify a file directly:
my $config = Config::ZOMG->new(file => '/path/to/my/application/my_application.cnf');
To later reload your configuration:
$config->reload;
$config = Config::ZOMG->new(...)
Returns a new "Config::ZOMG" object
You can configure the $config object by passing the following to new:
$config_hash = Config::ZOMG->open( ... )
As an alternative way to load a config "open" will pass given arguments to "new" then attempt to do "load"
Unlike "load" if no configuration files are found "open" will return "undef" (or the empty list)
This is so you can do something like:
my $config_hash = Config::ZOMG->open( '/path/to/application.cnf' ) or die "Couldn't find config file!"
In scalar context "open" will return the config hash, not the config object. If you want the config object call "open" in list context:
my ($config_hash, $config) = Config::ZOMG->open( ... )
You can pass any arguments to "open" that you would to "new"
$config->load
Load a config as specified by "new" and "ENV" and return a hash
This will only load the configuration once, so it's safe to call multiple times without incurring any loading-time penalty
$config->found
Returns a list of files found
If the list is empty then no files were loaded/read
$config->find
Returns a list of files that configuration will be loaded from. Use this method to check whether configuration files have changed, without actually reloading.
$config->clone
Return a clone of the configuration hash using Clone
This will load the configuration first, if it hasn't already
$config->reload
Reload the configuration, examining ENV and scanning the path anew
Returns a hash of the configuration
Config::JFDI
Catalyst::Plugin::ConfigLoader
Config::Any
Catalyst
Config::Merge
Config::General
This software is copyright (c) 2013 by Arthur Axel "fREW" Schmidt.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
2021-01-07 | perl v5.32.0 |