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

NAME

Config::FileManager - Configuration File Management with versionning

SYNOPSIS

The Config::FileManager module helps to manage configuration files. It provides versionning and check for updates of obsolete versions.

Usage:

  use Config::FileManager;

DESCRIPTION

The Config::FileManager module:

check wether the user configuration file version is up-to-date
can propose update taking into account user modifications
keep (and ca restore) the previous versions of the configuration file
search the configuration file in an ordered list of paths

EXPORT

  • the new operator can be given the following parameters:

    • toolname=<string> (mandatory)

      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.

    • interactive=<boolean>

      if set to 1, user is asked if some update is available. If set to 0, then update is automatic.

    Usage:

      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

    This method get/set the name of the tool for which the config file is.

    Usage:

      my $toolname = $cfg->toolname();
      $cfg->toolname("tool name");
  • Method filename

    This method get/set the file basename of the config file

    Usage:

      my $filename = $cfg->filename();
      $cfg->filename("file name");
  • Method 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).

    Usage:

      my @paths = $cfg->paths();
      $cfg->paths(qw(list ./of/paths));
  • Method interactive

    This method get/set the value of interactive...

    Usage:

      my $v = $cfg->interactive();
      $cfg->interactive(0); # or $cfg->interactive(1);
  • Method version

    This method get/set the current version of the config file

    Usage:

      my $vers = $cfg->version();
      $cfg->version("0.1.2");
  • Method versions

    This method returns (and prior computes if required) the array of all version's strings from the newest to the oldest.

    Usage:

      $cfg->versions();
  • Method 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.

    Usage:

      my $cfg_txt = $cfg->defaultContent();
      $cfg->defaultContent("# the default config content of the current version");
  • Method addPatch

    This method adds the patch from a given version of the default config file to the preceeding version of the default config.

    Usage:

      $cfg->addPatch(
                     "from" => "some version",
                     "to" => "previous version",
                     "diffs" => '
      @@ -1,1 +0,0 @@
      -# blablabla
      ');
  • Method 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.

    Usage:

      $cfg->getPath();
  • Method 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.

    Usage:

      $cfg->update();
  • Method getDefaultContent

    This method gets the default config content of the given version. If ommited, then uses the current version.

    Usage:

      $cfg->getDefaultContent();
      $cfg->getDefaultContent("a given version");

AUTHORS

Alban MANCHERON <alban.mancheron@lirmm.fr>, Nicolas PHILIPPE <nicolas.philippe@inserm.fr>.

COPYRIGHT AND LICENSE

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)

FRENCH

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".

ENGLISH

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".