.\" 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::JFDI 3pm" .TH Config::JFDI 3pm "2016-12-06" "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::JFDI \- Just * Do it: A Catalyst::Plugin::ConfigLoader\-style layer over Config::Any .SH "VERSION" .IX Header "VERSION" version 0.065 .SH "DESCRIPTION" .IX Header "DESCRIPTION" Config::JFDI is an implementation of Catalyst::Plugin::ConfigLoader that exists outside of Catalyst. .PP Essentially, Config::JFDI 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. .PP Config::JFDI will also look for special files that end with a \*(L"_local\*(R" 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 \&\*(L"standard\*(R" configuration via Hash::Merge::Simple. .PP Finally, you can override/modify the path search from outside your application, by setting the <\s-1NAME\s0>_CONFIG variable outside your application (where <\s-1NAME\s0> is the uppercase version of what you passed to Config::JFDI\->new). .SH "SYNPOSIS" .IX Header "SYNPOSIS" .Vb 1 \& use Config::JFDI; \& \& my $config = Config::JFDI\->new(name => "my_application", path => "path/to/my/application"); \& my $config_hash = $config\->get; .Ve .PP This will look for something like (depending on what Config::Any will find): .PP .Vb 1 \& 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,...} .Ve .PP \&... and load the found configuration information appropiately, with _local taking precedence. .PP You can also specify a file directly: .PP .Vb 1 \& my $config = Config::JFDI\->new(file => "/path/to/my/application/my_application.cnf"); .Ve .PP To later reload your configuration, fresh from disk: .PP .Vb 1 \& $config\->reload; .Ve .SH "Config::Loader" .IX Header "Config::Loader" We are currently kicking around ideas for a next-generation configuration loader. The goals are: .PP .Vb 5 \& * A universal platform for configuration slurping and post\-processing \& * Use Config::Any to do configuration loading \& * A sane API so that developers can roll their own loader according to the needs of their application \& * A friendly interface so that users can have it just DWIM \& * Host/application/instance specific configuration via _local and %ENV .Ve .PP Find more information and contribute at: .PP Roadmap: .PP Mailing list: .SH "Behavior change of the 'file' parameter in 0.06" .IX Header "Behavior change of the 'file' parameter in 0.06" In previous versions, Config::JFDI would treat the file parameter as a path parameter, stripping off the extension (ignoring it) and globbing what remained against all the extensions that Config::Any could provide. That is, it would do this: .PP .Vb 2 \& Config::JFDI\->new( file => \*(Aqxyzzy.cnf\*(Aq ); \& # Transform \*(Aqxyzzy.cnf\*(Aq into \*(Aqxyzzy.pl\*(Aq, \*(Aqxyzzy.yaml\*(Aq, \*(Aqxyzzy_local.pl\*(Aq, ... (depending on what Config::Any could parse) .Ve .PP This is probably not what people intended. Config::JFDI will now squeak a warning if you pass 'file' through, but you can suppress the warning with 'no_06_warning' or 'quiet_deprecation' .PP .Vb 2 \& Config::JFDI\->new( file => \*(Aqxyzzy.cnf\*(Aq, no_06_warning => 1 ); \& Config::JFDI\->new( file => \*(Aqxyzzy.cnf\*(Aq, quiet_deprecation => 1 ); # More general .Ve .PP If you *do* want the original behavior, simply pass in the file parameter as the path parameter instead: .PP .Vb 1 \& Config::JFDI\->new( path => \*(Aqxyzzy.cnf\*(Aq ); # Will work as before .Ve .SH "METHODS" .IX Header "METHODS" .ie n .SS "$config = Config::JFDI\->new(...)" .el .SS "\f(CW$config\fP = Config::JFDI\->new(...)" .IX Subsection "$config = Config::JFDI->new(...)" You can configure the \f(CW$config\fR object by passing the following to new: .PP .Vb 3 \& name The name specifying the prefix of the configuration file to look for and \& the ENV variable to read. This can be a package name. In any case, \& :: will be substituted with _ in and the result will be lowercased. \& \& To prevent modification of , pass it in as a scalar reference. \& \& path The directory to search in \& \& file Directly read the configuration from this file. Config::Any must recognize \& the extension. Setting this will override path \& \& no_local Disable lookup of a local configuration. The \*(Aqlocal_suffix\*(Aq option will be ignored. Off by default \& \& local_suffix The suffix to match when looking for a local configuration. "local" By default \& ("config_local_suffix" will also work so as to be drop\-in compatible with C::P::CL) \& \& no_env Set this to 1 to disregard anything in the ENV. The \*(Aqenv_lookup\*(Aq option will be ignored. Off by default \& \& env_lookup Additional ENV to check if $ENV{...} is not found \& \& driver A hash consisting of Config:: driver information. This is passed directly through \& to Config::Any \& \& install_accessor Set this to 1 to install a Catalyst\-style accessor as ::config \& You can also specify the package name directly by setting install_accessor to it \& (e.g. install_accessor => "My::Application") \& \& substitute A hash consisting of subroutines called during the substitution phase of configuration \& preparation. ("substitutions" will also work so as to be drop\-in compatible with C::P::CL) \& A substitution subroutine has the following signature: ($config, [ $argument1, $argument2, ... ]) \& \& path_to The path to dir to use for the _\|_path_to(...)_\|_ substitution. If nothing is given, then the \*(Aqhome\*(Aq \& config value will be used ($config\->get\->{home}). Failing that, the current directory will be used. \& \& default A hash filled with default keys/values .Ve .PP Returns a new Config::JFDI object .ie n .SS "$config_hash = Config::JFDI\->open( ... )" .el .SS "\f(CW$config_hash\fP = Config::JFDI\->open( ... )" .IX Subsection "$config_hash = Config::JFDI->open( ... )" As an alternative way to load a config, \->open will pass given arguments to \->new( ... ), then attempt to do \->load .PP Unlike \->get or \->load, if no configuration files are found, \->open will return undef (or the empty list) .PP This is so you can do something like: .PP .Vb 1 \& my $config_hash = Config::JFDI\->open( "/path/to/application.cnf" ) or croak "Couldn\*(Aqt find config file!" .Ve .PP In scalar context, \->open will return the config hash, \s-1NOT\s0 the config object. If you want the config object, call \->open in list context: .PP .Vb 1 \& my ($config_hash, $config) = Config::JFDI\->open( ... ) .Ve .PP You can pass any arguments to \->open that you would to \->new .ie n .SS "$config\->get" .el .SS "\f(CW$config\fP\->get" .IX Subsection "$config->get" .ie n .SS "$config\->config" .el .SS "\f(CW$config\fP\->config" .IX Subsection "$config->config" .ie n .SS "$config\->load" .el .SS "\f(CW$config\fP\->load" .IX Subsection "$config->load" Load a config as specified by \->new( ... ) and \s-1ENV\s0 and return a hash .PP These will only load the configuration once, so it's safe to call them multiple times without incurring any loading-time penalty .ie n .SS "$config\->found" .el .SS "\f(CW$config\fP\->found" .IX Subsection "$config->found" Returns a list of files found .PP If the list is empty, then no files were loaded/read .ie n .SS "$config\->clone" .el .SS "\f(CW$config\fP\->clone" .IX Subsection "$config->clone" Return a clone of the configuration hash using Clone .PP This will load the configuration first, if it hasn't already .ie n .SS "$config\->reload" .el .SS "\f(CW$config\fP\->reload" .IX Subsection "$config->reload" Reload the configuration, examining \s-1ENV\s0 and scanning the path anew .PP Returns a hash of the configuration .ie n .SS "$config\->substitute( , , ... )" .el .SS "\f(CW$config\fP\->substitute( , , ... )" .IX Subsection "$config->substitute( , , ... )" For each given , if looks like a substitution specification, then run the substitution macro on and store the result. .PP There are three default substitutions (the same as Catalyst::Plugin::ConfigLoader) .IP "\(bu" 4 \&\f(CW\*(C`_\|_HOME_\|_\*(C'\fR \- replaced with \f(CW\*(C`$c\->path_to(\*(Aq\*(Aq)\*(C'\fR .IP "\(bu" 4 \&\f(CW\*(C`_\|_path_to(foo/bar)_\|_\*(C'\fR \- replaced with \f(CW\*(C`$c\->path_to(\*(Aqfoo/bar\*(Aq)\*(C'\fR .IP "\(bu" 4 \&\f(CW\*(C`_\|_literal(_\|_FOO_\|_)_\|_\*(C'\fR \- leaves _\|_FOO_\|_ alone (allows you to use \&\f(CW\*(C`_\|_DATA_\|_\*(C'\fR as a config value, for example) .PP The parameter list is split on comma (\f(CW\*(C`,\*(C'\fR). .PP You can define your own substitutions by supplying the substitute option to \->new .SH "SEE ALSO" .IX Header "SEE ALSO" Catalyst::Plugin::ConfigLoader .PP Config::Any .PP Catalyst .PP Config::Merge .PP Config::General .SH "AUTHOR" .IX Header "AUTHOR" Robert Krimen .SH "COPYRIGHT AND LICENSE" .IX Header "COPYRIGHT AND LICENSE" This software is copyright (c) 2011 by Robert Krimen. .PP This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.