Config::FileManager - Configuration File Management with versionning
The Config::FileManager module helps to manage configuration files. It provides versionning and check for updates of obsolete versions.
Usage:
use Config::FileManager;
The Config::FileManager module:
the new operator can be given the following parameters:
toolname=<string> (mandatory)
toolname=<string>
sets the name of the tool the configuration file is designed for.
version=<string>
sets the current version of the configuration file (can be the same as the tool version).
filename=<string>
sets the base file name of the configuration file.
paths=[qw(string array of paths)]
sets the ordered list of paths where the configuration file will be searched. The special __APPDIR__ is OS dependent and is the user application directory.
__APPDIR__
interactive=<boolean>
if set to 1, user is asked if some update is available. If set to 0, then update is automatic.
my $cfg = new Config( # Mandatory settings "toolname" => "tool name", # Optional settings "version" => "version string", # default to undef "filename" => "config file basename", # default to "config" "paths" => [qw(list of/paths /to/look ./for)], # default to [qw(. __APPDIR__ /usr/local/etc /etc)], "interactive" => 0, # default to 1 );
Method toolname
toolname
This method get/set the name of the tool for which the config file is.
my $toolname = $cfg->toolname(); $cfg->toolname("tool name");
Method filename
filename
This method get/set the file basename of the config file
my $filename = $cfg->filename(); $cfg->filename("file name");
Method paths
paths
This method get/set the paths where the config file should be found. The special __APPDIR__ path is OS dependant (see File::HomeDir module documentation).
my @paths = $cfg->paths(); $cfg->paths(qw(list ./of/paths));
Method interactive
interactive
This method get/set the value of interactive...
my $v = $cfg->interactive(); $cfg->interactive(0); # or $cfg->interactive(1);
Method version
version
This method get/set the current version of the config file
my $vers = $cfg->version(); $cfg->version("0.1.2");
Method versions
versions
This method returns (and prior computes if required) the array of all version's strings from the newest to the oldest.
$cfg->versions();
Method defaultContent
defaultContent
This method get/set the current default content of the config file. You can (should) use '__VERSION__' instead of giving it explicitely. In such case, it will be replaced by the corresponding version string.
my $cfg_txt = $cfg->defaultContent(); $cfg->defaultContent("# the default config content of the current version");
Method addPatch
addPatch
This method adds the patch from a given version of the default config file to the preceeding version of the default config.
$cfg->addPatch( "from" => "some version", "to" => "previous version", "diffs" => ' @@ -1,1 +0,0 @@ -# blablabla ');
Method getPath
getPath
This method gets (and prior computes if required) the path where the config file is. If no config file is found, then the default current config file is created in the "correct" place.
$cfg->getPath();
Method update
update
This method check if the current config file is up-to-date and proposes an update if it is not. The update tries to preserve custom user's settings.
$cfg->update();
Method getDefaultContent
getDefaultContent
This method gets the default config content of the given version. If ommited, then uses the current version.
$cfg->getDefaultContent(); $cfg->getDefaultContent("a given version");
Alban MANCHERON <alban.mancheron@lirmm.fr>, Nicolas PHILIPPE <nicolas.philippe@inserm.fr>.
Copyright (C) 2012-2013 -- LIRMM/UM2 (Laboratoire d'Informatique, de Robotique et de Micro�lectronique de Montpellier / Universit� de Montpellier 2) IRB/INSERM (Institut de Recherche en Bioth�rapie / Institut National de la Sant� et de la Recherche M�dicale)
Ce fichier fait partie du Pipeline de traitement de donn�es NGS de la plateforme ATGC lab�lis�e par le GiS IBiSA.
Ce logiciel est r�gi par la licence CeCILL soumise au droit fran�ais et respectant les principes de diffusion des logiciels libres. Vous pouvez utiliser, modifier et/ou redistribuer ce programme sous les conditions de la licence CeCILL telle que diffus�e par le CEA, le CNRS et l'INRIA sur le site "http://www.cecill.info".
This File is part of the NGS data processing Pipeline of the ATGC accredited by the IBiSA GiS.
This software is governed by the CeCILL license under French law and abiding by the rules of distribution of free software. You can use, modify and/ or redistribute the software under the terms of the CeCILL license as circulated by CEA, CNRS and INRIA at the following URL "http://www.cecill.info".
To install Config::FileManager, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Config::FileManager
CPAN shell
perl -MCPAN -e shell install Config::FileManager
For more information on module installation, please visit the detailed CPAN module installation guide.