Ropkg::rsync::node
A node is a rsync module. A node is formed of zero or more atoms.
Example:
[debian] path = /var/ftp/pub/mirrors/debian.org/ #This comment will show on rsync -v comment = Debian Mirror list = yes
[debian] is the node. The node name is debian. The node has 4 atoms:
#!/usr/bin/perl
use strict; use warnings;
sub main { my $node = new RoPkg::Rsync::Node(node_name => 'debian');
$node->AddParam('path', '/var/ftp/pub/mirrors/debian.org'); $node->AddComment('#This comment will show on rsync -v'); $node->AddParam('comment', 'Debian Mirror'); $node->AddParam('list', 'yes');
print $node->ToString(); }
main();
The result is:
[debian] path = /var/ftp/pub/mirrors/debian.org #This comment will show on rsync -v comment = Debian Mirror list = yes
All methods, throw the OutsideClass exception, if you use them as class methods. Besides OutsideClass the methods are throwing other exceptions as well. Refer to each method documentation for more information.
\$1
The constructor of the class. Expects a hash as parameter. At this time, the only valid option is node_name . Any other option will be discarded. The node_name is a required parameter. If is not defined, a Param::Missing exception will be raised.
Example:
my $node = new RoPkg::Rsync::Node(node_name => 'debian'); Add a new atom to the node. The atom details (type, name and value) are keys from the hash. All three parameters must be defined. There are 2 special cases: when the atom is a comment or a blank. In both cases, RoPkg::Rsync::Node generates a name for them. If the atom is a comment or a blank the returned value is the name of the atom. If the atom is a parameter, the total number of atoms for this node is returned.
Example:
$node->Add( type => 'param', name => 'path', value => '/var/ftp/pub/mirrors/debian.org', );
The returned value is the total number of atoms for this node.
Example:
$node->Add( type => 'comment', value => '#This comment will show on rsync -v', );
The returned value is the name of the atom (the name is autogenerated).
Exceptions: A wrapper around Add provided for comodity. See Add documentation for more details about the behaviour. A wrapper around Add provided for comodity. See Add documentation for more details about the behaviour. A wrapper around Add provided for comodity. See Add documentation for more details about the behaviour. Returns a RoPkg::Rsync::Atom object based on parameters specified in %atom_details. The %atom_details fields can be: type, name and value. type and value must be specified.
Exceptions:
Take note that only the first object who match the criterias is returned. A wrapper around GetAtom provided for comodity. See GetAtom documentation for more details about the behaviour. A wrapper around GetAtom provided for comodity. See GetAtom documentation for more details about the behaviour. A wrapper around GetAtom provided for comodity. See GetAtom documentation for more details about the behaviour. Returns a array with all the atoms of the node. In scalar context returns the number of atoms. Returns the number of atoms for this node. Returns 1 if the $atom object is already a atom for this node, 0 otherwise. Removes the atom those name is $atom_name. Returns 1 on success (the atom was found and removed), 0 otherwise. get/set method for node name. Using this method you can change the node name or find it. Returns the string representation of the node. If $indent is true, the atoms are indented. If $include_node_name is true, the node name will be included in the string.
Example:
$node = new RoPkg::Rsync::Node(node_name => 'debian'); $node->AddParam('gid', 'users');
print $node->ToString(0, 0),$/, $node->ToString(0, 1),$/, $node->ToString(1, 1),$/, $node->ToString(),$/;
The result is: gid = users [debian] gid = users; [debian]
gid = users
[debian]
gid = users
perl 5.008 (or later) is required. Besides perl, you must have the following:
RoPkg::Rsync::Atom 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.