RoPkg:...::Node(3pm)
π RoPkg::Rsync::Node π
okay bestie, so this is the page for RoPkg::Rsync::Node β it lives in the User Contributed Perl Documentation section of your man pages, and it's literally the node half of the RoPkg::Rsync crew. pull up a chair, grab a boba, we're gonna get you fluent in nodes π§β¨
πΈ NAME πΈ
RoPkg::Rsync::Node β the class that holds one rsync module (a "node") made out of zero or more atoms. no cap. π
π¦ DESCRIPTION π¦
so a node is a rsync module. and a node is made of zero or more atoms. that's the whole vibe.
here's an example, look at it, it's giving config file:
[debian]
path = /var/ftp/pub/mirrors/debian.org/
#This comment will show on rsync -v
comment = Debian Mirror
list = yes
okay so [debian] is the node. the node name is debian. and this node has 4 atoms:
- param atom (
path) - comment atom (the comment)
- param atom (
comment) - param atom (
list)
see? atoms are just the lil pieces. obsessed. β¨
π SYNOPSIS π
here's the whole thing in action:
#!/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();
and the result is chef's kiss:
[debian]
path = /var/ftp/pub/mirrors/debian.org
#This comment will show on rsync -v
comment = Debian Mirror
list = yes
slay. π₯
π METHODS π
heads up bestie: all the methods throw theOutsideClassexception if you use them as class methods. and besidesOutsideClass, the methods throw other exceptions too. every method's own docs have the deets, so read the one you're calling, mwah π
π new(%hash)
the constructor, the main character of the class. it expects a hash as its parameter. right now the only valid option is node_name. any other option? discarded. gone. not invited. π
node_name is a required parameter. if it's not defined, a Param::Missing exception gets raised. no node_name, no node.
example:
my $node = new RoPkg::Rsync::Node(node_name => 'debian');
π Add(%atom_details)
adds a new atom to the node. the atom details (type, name and value) are keys of the hash. all three parameters must be defined.
there are 2 special cases: when the atom is a comment or a blank. in both of those 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:
Param::Missingβ$atom_details{type}is not definedParam::Wrong=$atom_details{name}or$atom_details{value}are not defined
π AddParam($pname, $pvalue)
a wrapper around Add provided for comodity. see the Add documentation for more details about the behaviour. π«Ά
π AddComment($comment_value)
a wrapper around Add provided for comodity. see the Add documentation for more details about the behaviour. π«Ά
π AddBlank($blank_value)
a wrapper around Add provided for comodity. see the Add documentation for more details about the behaviour. π«Ά
π GetAtom(%atom_details)
returns a RoPkg::Rsync::Atom object based on the parameters you specify in %atom_details. the %atom_details fields can be: type, name and value. type and value must be specified.
exceptions:
Param::Missingβ type/name were not specifiedParam::Unknownβ no objects were found
take note bestie: only the first object who match the criterias is returned. first come, first served, periodt. π
π GetParam($name)
a wrapper around GetAtom provided for comodity. see the GetAtom documentation for more details about the behaviour. π«Ά
π GetComment($name)
a wrapper around GetAtom provided for comodity. see the GetAtom documentation for more details about the behaviour. π«Ά
π GetBlank($name)
a wrapper around GetAtom provided for comodity. see the GetAtom documentation for more details about the behaviour. π«Ά
π GetAll()
returns an array with all the atoms of the node. in scalar context it returns the number of atoms. both? iconic. β¨
π GetAtomsNo()
returns the number of atoms for this node.
π Has($atom)
returns 1 if the $atom object is already an atom for this node, 0 otherwise.
π Delete($atom_name)
removes the atom whose name is $atom_name. returns 1 on success (the atom was found and removed), 0 otherwise. bye bestie π
π Name($node_name)
get/set method for the node name. using this method you can change the node name or find it. glow up whenever you want π
π ToString($indent, $include_node_name)
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
(and yes, that gid = users; with the semicolon is literally what it prints, i don't make the rules π« )
π§ PREREQUISITES π§
perl 5.008 (or later) is required. besides perl, you must have the following:
RoPkg::ExceptionsScalar::UtilEnglish
don't skip these, bestie, they're the support squad π«Ά
β SEE ALSO β
RoPkg::Rsync::Atom RoPkg::Rsync::ConfFile RoPkg::Exceptions
π AUTHOR π
Subredu Manuel <diablo@iasi.roedu.net>
π LICENSE π
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 LICENSE file contains the full text of the license.
aaaand that's the whole page, bestie!! π this one shipped with perl v5.32.1 and it's dated 2021-12-26 β so go forth, build your nodes, and remember: every single atom counts. mwah ππβ¨
π¦ where this page comes from
- ubuntu jammy: libropkg-perl 0.4-1.4
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms