.\" Automatically generated by Pod::Man 4.07 (Pod::Simple 3.32) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .if !\nF .nr F 0 .if \nF>0 \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} .\} .\" ======================================================================== .\" .IX Title "Config::Any 3pm" .TH Config::Any 3pm "2017-06-18" "perl v5.24.1" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" Config::Any \- Load configuration from different file formats, transparently .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& use Config::Any; \& \& my $cfg = Config::Any\->load_stems({stems => \e@filepath_stems, ... }); \& # or \& my $cfg = Config::Any\->load_files({files => \e@filepaths, ... }); \& \& for (@$cfg) { \& my ($filename, $config) = %$_; \& $class\->config($config); \& warn "loaded config from file: $filename"; \& } .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" Config::Any provides a facility for Perl applications and libraries to load configuration data from multiple different file formats. It supports \s-1XML, YAML, JSON,\s0 Apache-style configuration, Windows \s-1INI\s0 files, and even Perl code. .PP The rationale for this module is as follows: Perl programs are deployed on many different platforms and integrated with many different systems. Systems administrators and end users may prefer different configuration formats than the developers. The flexibility inherent in a multiple format configuration loader allows different users to make different choices, without generating extra work for the developers. As a developer you only need to learn a single interface to be able to use the power of different configuration formats. .SH "INTERFACE" .IX Header "INTERFACE" .SS "load_files( \e%args )" .IX Subsection "load_files( %args )" .Vb 4 \& Config::Any\->load_files( { files => \e@files } ); \& Config::Any\->load_files( { files => \e@files, filter => \e&filter } ); \& Config::Any\->load_files( { files => \e@files, use_ext => 1 } ); \& Config::Any\->load_files( { files => \e@files, flatten_to_hash => 1 } ); .Ve .PP \&\f(CW\*(C`load_files()\*(C'\fR attempts to load configuration from the list of files passed in the \f(CW\*(C`files\*(C'\fR parameter, if the file exists. .PP If the \f(CW\*(C`filter\*(C'\fR parameter is set, it is used as a callback to modify the configuration data before it is returned. It will be passed a single hash-reference parameter which it should modify in-place. .PP If the \f(CW\*(C`use_ext\*(C'\fR parameter is defined, the loader will attempt to parse the file extension from each filename and will skip the file unless it matches a standard extension for the loading plugins. Only plugins whose standard extensions match the file extension will be used. For efficiency reasons, its use is encouraged, but be aware that you will lose flexibility \*(-- for example, a file called \f(CW\*(C`myapp.cfg\*(C'\fR containing \s-1YAML\s0 data will not be offered to the \s-1YAML\s0 plugin, whereas \f(CW\*(C`myapp.yml\*(C'\fR or \f(CW\*(C`myapp.yaml\*(C'\fR would be. .PP When the \f(CW\*(C`flatten_to_hash\*(C'\fR parameter is defined, the loader will return a hash keyed on the file names, as opposed to the usual list of single-key hashes. .PP \&\f(CW\*(C`load_files()\*(C'\fR also supports a 'force_plugins' parameter, whose value should be an arrayref of plugin names like \f(CW\*(C`Config::Any::INI\*(C'\fR. Its intended use is to allow the use of a non-standard file extension while forcing it to be offered to a particular parser. It is not compatible with 'use_ext'. .PP You can supply a \f(CW\*(C`driver_args\*(C'\fR hashref to pass special options to a particular parser object. Example: .PP .Vb 3 \& Config::Any\->load_files( { files => \e@files, driver_args => { \& General => { \-LowerCaseNames => 1 } \& } ) .Ve .SS "load_stems( \e%args )" .IX Subsection "load_stems( %args )" .Vb 4 \& Config::Any\->load_stems( { stems => \e@stems } ); \& Config::Any\->load_stems( { stems => \e@stems, filter => \e&filter } ); \& Config::Any\->load_stems( { stems => \e@stems, use_ext => 1 } ); \& Config::Any\->load_stems( { stems => \e@stems, flatten_to_hash => 1 } ); .Ve .PP \&\f(CW\*(C`load_stems()\*(C'\fR attempts to load configuration from a list of files which it generates by combining the filename stems list passed in the \f(CW\*(C`stems\*(C'\fR parameter with the potential filename extensions from each loader, which you can check with the \&\f(CW\*(C`extensions()\*(C'\fR classmethod described below. Once this list of possible filenames is built it is treated exactly as in \f(CW\*(C`load_files()\*(C'\fR above, as which it takes the same parameters. Please read the \f(CW\*(C`load_files()\*(C'\fR documentation before using this method. .SS "finder( )" .IX Subsection "finder( )" The \f(CW\*(C`finder()\*(C'\fR classmethod returns the Module::Pluggable::Object object which is used to load the plugins. See the documentation for that module for more information. .SS "plugins( )" .IX Subsection "plugins( )" The \f(CW\*(C`plugins()\*(C'\fR classmethod returns the names of configuration loading plugins as found by Module::Pluggable::Object. .SS "extensions( )" .IX Subsection "extensions( )" The \f(CW\*(C`extensions()\*(C'\fR classmethod returns the possible file extensions which can be loaded by \f(CW\*(C`load_stems()\*(C'\fR and \f(CW\*(C`load_files()\*(C'\fR. This may be useful if you set the \f(CW\*(C`use_ext\*(C'\fR parameter to those methods. .SH "DIAGNOSTICS" .IX Header "DIAGNOSTICS" .ie n .IP """No files specified!"" or ""No stems specified!""" 4 .el .IP "\f(CWNo files specified!\fR or \f(CWNo stems specified!\fR" 4 .IX Item "No files specified! or No stems specified!" The \f(CW\*(C`load_files()\*(C'\fR and \f(CW\*(C`load_stems()\*(C'\fR methods will issue this warning if called with an empty list of files/stems to load. .ie n .IP """_load requires a arrayref of file paths""" 4 .el .IP "\f(CW_load requires a arrayref of file paths\fR" 4 .IX Item "_load requires a arrayref of file paths" This fatal error will be thrown by the internal \f(CW\*(C`_load\*(C'\fR method. It should not occur but is specified here for completeness. If your code dies with this error, please email a failing test case to the authors below. .SH "CONFIGURATION AND ENVIRONMENT" .IX Header "CONFIGURATION AND ENVIRONMENT" Config::Any requires no configuration files or environment variables. .SH "DEPENDENCIES" .IX Header "DEPENDENCIES" Module::Pluggable::Object .PP And at least one of the following: Config::General Config::Tiny \&\s-1JSON\s0 \&\s-1YAML\s0 JSON::Syck YAML::Syck XML::Simple .SH "INCOMPATIBILITIES" .IX Header "INCOMPATIBILITIES" None reported. .SH "BUGS AND LIMITATIONS" .IX Header "BUGS AND LIMITATIONS" No bugs have been reported. .PP Please report any bugs or feature requests to \&\f(CW\*(C`bug\-config\-any@rt.cpan.org\*(C'\fR, or through the web interface at . .SH "AUTHOR" .IX Header "AUTHOR" Joel Bernstein .SH "CONTRIBUTORS" .IX Header "CONTRIBUTORS" This module was based on the original Catalyst::Plugin::ConfigLoader module by Brian Cassidy \f(CW\*(C`\*(C'\fR. .PP With ideas and support from Matt S Trout \f(CW\*(C`\*(C'\fR. .PP Further enhancements suggested by Evan Kaufman \f(CW\*(C`\*(C'\fR. .SH "LICENCE AND COPYRIGHT" .IX Header "LICENCE AND COPYRIGHT" Copyright (c) 2006, Portugal Telecom \f(CW\*(C`http://www.sapo.pt/\*(C'\fR. All rights reserved. Portions copyright 2007, Joel Bernstein \f(CW\*(C`\*(C'\fR. .PP This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself. See perlartistic. .SH "DISCLAIMER OF WARRANTY" .IX Header "DISCLAIMER OF WARRANTY" \&\s-1BECAUSE THIS SOFTWARE IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE SOFTWARE, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE SOFTWARE \*(L"AS IS\*(R" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE SOFTWARE IS WITH YOU. SHOULD THE SOFTWARE PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR, OR CORRECTION.\s0 .PP \&\s-1IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE SOFTWARE AS PERMITTED BY THE ABOVE LICENCE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE SOFTWARE \s0(\s-1INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE SOFTWARE TO OPERATE WITH ANY OTHER SOFTWARE\s0), \s-1EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.\s0 .SH "SEE ALSO" .IX Header "SEE ALSO" Catalyst::Plugin::ConfigLoader \&\*(-- now a wrapper around this module.