The smallest unit in a rsync configuration file
#!/usr/bin/perl
use strict; use warnings;
use RoPkg::Rsync::Atom;
sub main { my $a = new RoPkg::Rsync::Atom( type => 'param', name => 'uid', value => 'nobody', );
print $a->ToString(0),$/;
return 0; }
main();
RoPkg::Rsync::Atom is a class used by RoPkg::Rsync modules. The Atom is considered the smallest part of any rsync configuration file. An atom can be (at this moment):
All methods, throw the OutsideClass exception, if you use them as class methods.
Example:
perl -MRoPkg::Rsync::Atom -e 'RoPkg::Rsync::Atom->Type;' Called outside class instance
Besides OutsideClass the methods are throwing other exceptions as well. Refer to each method documentation for more information.
\$1
The constructor of the class. new accepts 3 parameters grouped inside a hash:
The type parameter must always be present. If the type parameter is not present, a Param::Missing exception is raised. At this moment, the atoms have 3 types:
If the value of the type parameter is not one of the ones specified a Param::Wrong exception is raised.
Examples:
example 1 (param):
my $a = new RoPkg::Rsync::Atom( type => 'param', name => 'gid', value => 'users', );
example 2 (param):
my $a = new RoPkg::Rsync::Atom(type => 'param'); $a->Name('gid'); $a->Value('users'); print 'Name of the atom is:',$a->Name,$/;
example 3 (comment):
my $a = new RoPkg::Rsync::Atom( type => 'comment', value => '# this is the group id', );
example 4 (blank):
my $a = new RoPkg::Rsync::Atom( type => 'blank', value => q{ }, ); The Name method is a get/set method. If $new_name exists (and his value is defined) then the set behaviour is selected, otherwise the method acts as a get method. Returns the name of the atom. The Value method is a get/set method. If $new_value exists (and his value is defined) then the set behaviour is selected, otherwise the method acts as a get method. Returns the value of the atom. Returns the string representation of the atom. Accepts 2 parameters: indent and spaces. $indent is a true/false value specifing that the string representation should be prefixed with a tab character; $spaces is used to compute the number of spaces that should be added after the atom name, so that the total length of the parameter name to match the $spaces value.
Example:
my $a = new RoPkg::Rsync::Atom( type => 'param', name => 'gid', value => 'users', );
print $a->ToString(0, 6),$/, $a->ToString(0, 5),$/, $a->ToString(0, 4),$/, $a->ToString(0, 3),$/, $a->ToString(1, 6),$/, $a->ToString(1, 5),$/, $a->ToString(1, 4),$/, $a->ToString(1, 3),$/;
The result is: gid = users gid = users gid = users gid = users
gid = users gid = users gid = users gid = users
Returns the type (string representation) of the atom.
perl 5.008 (or later) is required. Besides perl, you must have the following:
RoPkg::Rsync::Node RoPkg::Rsync::ConfFile RoPkg::Exceptions
Subredu Manuel <[email protected]>
Copyright (C) 2005 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 \s-1LICENSE\s0 file contains the full text of the license.