The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Banal::Config - A convenient wrapper around Config::General

SYNOPSIS

Quick summary of what the module does.

Perhaps a little code snippet.

    use Banal::Config;

    my $foo = Banal::Config->new(options=>{...}, switches=>{...});
    ...

EXPORT

None.

EXPORT_OK

None.

CLASS METHODS

get_default_config_term()

This "term" is in several places, such as : - for generating the name of the default command line switch possibly holding the config file path (used when no explicit config file path is given) - for generating the name of the default environment variable possibly holding the config file path (used when no explicit config file path is given) - for generating the default base name of the config file, which in turn is searched in several places (used when no explicit config file path is given) - for generating the default configuration context within the config file.

By default, returns the base name of the main program (script).

Can be overridden.

get_default_config_file_base_name()

The default base name of the configuration file, which will be searched in several places when trying to "guess" the config file path. This would only be needed when there is no explicit config file path given.

By default, simply calls "get_default_config_term()".

guess_config_file_path()

A call to this class method is made in order to build the default value of the "source" attribute, which will be used as the source path for the config file UNLESS one is explicetly given in the options argument to new().

The current implementation goes as follows: - It will first try suitable "switches". If one that designates the config fie path is defined, the that one will be return. By default, here are those switches that will be checked for definedness: cfg_[%TERM%] [%TERM%]_cfg cfg

                        where TERM is obtained by a call to get_default_config_term()
                        
        - Then, we will see if there is an ENVIRONMENT variable, 
                        [%TERM%]_CFG
                        CFG_[%TERM%]
                        
        - or else, we will use as config, the first file that exists in the following list: 

                        "./test/etc/"   .       $base_name . ".conf",   # this one is for testing purposes during "make test"
                        "~/."                   .   $base_name . ".conf",
                        "/etc/"                 .   $base_name . ".conf",
                        "."                     .   $base_name . ".conf",

                where $base_name is obtained by a call to get_default_config_file_base_name()
                
        

get_possible_option_names_for_config_file_path

Used by guess_config_file_path() to check for command line switches.

Currently returns the list: cfg_[%TERM%] [%TERM%]_cfg cfg where TERM is obtained by a call to get_default_config_term()

get_possible_environment_variable_names_for_config_file_path

Used by guess_config_file_path() to check for ENVIRONMENT variables.

Currently returns the list: [%TERM%]_CFG CFG_[%TERM%]

where TERM is obtained by a call to get_default_config_term()

get_possible_config_file_paths()

Used by guess_config_file_path() after trying command line swictches and ENV variables. At this point (when everything else is exhausted), the first file that exists in the list returned by this function will be used as the config file.

Currently returns the list:

                                                "./test/etc/"   .       $base_name . ".conf",   # this one is for testing purposes during "make test"
                                                "~/."                   .   $base_name . ".conf",
                                                "/etc/"                 .   $base_name . ".conf",
                                                "."                     .   $base_name . ".conf",

where $base_name is obtained by a call to get_default_config_file_base_name()

METHODS

get_cfg()

Return the configuration value given by key (which may also be an ARRAY of path segments, or one long config key in path notation, or a mix).

If the value for the given key is not defined, it will be tried in outer contexts (in concentric circles) until it is found. This way, it is possible to set a value in an outer configuration context, and use it within.

A simple call to:

         $self->grab_cfg(key=>[@_]);

grab_cfg()

Return the configuration value given by key (which may also be an ARRAY of path segments, or one long config key in path notation, or a mix).

If the value for the given key is not defined, it will be tried in outer contexts (in concentric circles) until it is found. This way, it is possible to set a value in an outer configuration context, and use it within.

        $value = $c->grab_cfg(key => {..}, options => {..}, context=>{..})

By default: options : $self->default_options_for_banal_get_data() context : $self->cfg_context();

reload()

Reload the configuratoin file from disk.

load()

Reload the configuratoin file from disk (when the first such call needs to be distinguished, as opposed to reload().)

AUTHOR

"aulusoy", <"dev (at) ulusoy.name">

BUGS

Please report any bugs or feature requests to bug-banal-config at rt.cpan.org, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Banal-Config. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.

SUPPORT

You can find documentation for this module with the perldoc command.

    perldoc Banal::Config

You can also look for information at:

ACKNOWLEDGEMENTS

LICENSE AND COPYRIGHT

Copyright 2014 "aulusoy".

This program is free software; you can redistribute it and/or modify it under the terms of the the Artistic License (2.0). You may obtain a copy of the full license at:

http://www.perlfoundation.org/artistic_license_2_0

Any use, modification, and distribution of the Standard or Modified Versions is governed by this Artistic License. By using, modifying or distributing the Package, you accept this license. Do not use, modify, or distribute the Package, if you do not accept this license.

If your Modified Version has been derived from a Modified Version made by someone other than you, you are nevertheless required to ensure that your Modified Version complies with the requirements of this license.

This license does not grant you the right to use any trademark, service mark, tradename, or logo of the Copyright Holder.

This license includes the non-exclusive, worldwide, free-of-charge patent license to make, have made, use, offer to sell, sell, import and otherwise transfer the Package with respect to any patent claims licensable by the Copyright Holder that are necessarily infringed by the Package. If you institute patent litigation (including a cross-claim or counterclaim) against any party alleging that the Package constitutes direct or contributory patent infringement, then this Artistic License to you shall terminate on the date that such litigation is filed.

Disclaimer of Warranty: THE PACKAGE IS PROVIDED BY THE COPYRIGHT HOLDER AND CONTRIBUTORS "AS IS' AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES. THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT ARE DISCLAIMED TO THE EXTENT PERMITTED BY YOUR LOCAL LAW. UNLESS REQUIRED BY LAW, NO COPYRIGHT HOLDER OR CONTRIBUTOR WILL BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING IN ANY WAY OUT OF THE USE OF THE PACKAGE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.