NAME

Rsync::Config

VERSION

0.2

DESCRIPTION

Rsync::Config is a module who can be used to create rsync configuration files. A configuration file (from Rsync::Config point of view) is made by atoms and modules with atoms. A atom is the smallest piece from the configuration file. This module inherits from Rsync::Config::Module .

INHERITANCE

Objects from Rsync::Config inherits as in the next scheme

                        /--- Rsync::Config::Atom
Rsync::Config::Renderer 
                        \--- Rsync::Config::Module --- Rsync::Config

SYNOPSIS

use Rsync::Config;
use Rsync::Config::Atom;
use Rsync::Config::Module;

sub main {
  my ($conf, $module);

  $conf = new Rsync::Config();
  $conf->add_comment('Main configuration file for our rsync daemon');
  $conf->add_atom('read only','yes');
  $conf->add_atom('chroot','yes');

  $module = new Rsync::Config::Module(name => 'cpan');
  $module->add_atom('path','/var/ftp/pub/mirrors/ftp.cpan.org/');
  $module->add_atom('comment', 'CPAN mirror');

  $conf->add_module($module);
  $conf->to_file('/etc/rsyncd.conf');
}

SUBROUTINES/METHODS

Each subroutine and/or method throws REX::OutsideClass exception if called outside class instance. Besides this exception, each method may throw another exception. Please read the documentation for each method for more information

new(%opt)

The class contructor. At this moment, only one parameter can be specified: indent (true/false value)

add_module($module)

Adds the $module (a instance of Rsync::Config::Module) to the list of modules. If $module is not defined REX::Param::Missing exception is throwned. If $module is not a instance of Rsync::Config::Module, REX::Param::Invalid exception is throwned.

modules_no()

Returns the number of modules

to_string($indent)

Returns the string representation for this configuration file. If $indent is specified, a best effort indentation is tried. Please note that $indent has high preference over option $indent specified at new()

to_file($filename, $indent)

Writes the configuration into the file specified by $filename. if $indent is specified, a best effort indentation is tried. Please note that $indent has high preference over option $indent specified at new() The following exceptions may be throwned:

REX::Param::Missing - $filename not specified
REX::File::Create - file could not be created

If the file already exists, the content of that file will be lost.

DEPENDENCIES

Rsync::Config depends on the following modules:

English
Scalar::Util
CLASS
Rsync::Config::Module

DIAGNOSTICS

All tests are located into t directory.

PERL CRITIC

This module is perl critic level 1 compliant.

CONFIGURATION AND ENVIRONMENT

This module does not use any configuration files or environment variables. The used modules however may use such things. Please refer to each module man page for more information.

INCOMPATIBILITIES

None known to the author

BUGS AND LIMITATIONS

*) Using atoms with values 0 or undef will trigger exceptions.
*) Parsing of rsync configuration file is not yet implemented
*) Global atoms can't be indented

SEE ALSO

Rsync::Config::Exceptions Rsync::Config::Module Rsync::Config::Atom

AUTHOR

Subredu Manuel <diablo@packages.ro>

LICENSE AND COPYRIGHT

Copyright (C) 2006 Subredu Manuel. All Rights Reserved. This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself. The LICENSE file contains the full text of the license.