RoPkg:...nfFile(3pm)

πŸ“¦ version 0.4, in ubuntu jammy

✨ NAME ✨

RoPkg::Rsync::ConfFile β€” bestie, it's a whole module, and yes it's giving main character energy πŸ’…


πŸ’– DESCRIPTION πŸ’–

Okay so listen. RoPkg::Rsync::ConfFile is a class you use to mess with rsync configuration files. And the way it does it?? It's so respectful of your file, fr fr β€” it can keep the order of the modules exactly like you left them, and it even keeps your comments and your empty lines intact. No cap, nothing gets yeeted that you didn't ask to get yeeted. πŸ¦‹


🌸 SYNOPSIS 🌸

#!/usr/bin/perl

use warnings;
use strict;

sub main {
  my $cf = new RoPkg::Rsync::ConfFile(filename => '/etc/rsyncd.conf');

  $cf->Write('/tmp/new_rsyncd.conf');
  return 0;
}

main();

πŸŽ€ METHODS πŸŽ€

Heads up bestie: all of these methods throw the OutsideClass exception if you go and use them as class methods. Rude of you, honestly. πŸ™ˆ And besides OutsideClass, the methods are throwing other exceptions too, so don't @ me β€” refer to each method's own documentation for the full tea. πŸ’€

🧚 new(%hash)

The class constructor, the origin story, the birth of your object. Accepts a hash as its parameter. At this moment only one parameter can be specified inside the hash: filename. If that parameter is present, the file you specified gets parsed and loaded right into the object. Slay. ✨

πŸ“ AddParam($pname, $pvalue)

Add a new global parameter named $pname with value $value. πŸ’…

πŸ“ AddComment($pval)

Add a new global comment with value $pval. πŸŽ€

πŸ“ AddBlank($bval)

Add a new global blank line with value $bval. 🫢

πŸ“ AddNode($node)

Adds a new RoPkg::Rsync::Node object to the current object. But bestie, before the node gets added, the nodes list gets checked for duplicates of the object β€” and if a duplicate is found, the method just… does nothing. Iconic restraint, honestly. 🌈

Exceptions:

  • If $node is not a instance of RoPkg::Rsync::Node, the Param::Wrong exception is raised. 🚨

πŸ“ DelNode($node_name)

Removes a node from the nodes list. The nodes are searched by their names. Returns -1 if the node was not found, and the new number of nodes otherwise. 🌸

πŸ“ HasNode($node_name)

Returns 1 if the node with name $node_name was found in the nodes list, 0 otherwise. Simple as that, periodt. ✨

πŸ“ Clean()

Clean the object. Removes all information (the nodes list, statistics, etc). Always returns 1. It's giving factory reset. πŸ’€

πŸ“ Parse($filename)

Parse the configuration file $filename and returns the number of nodes. Now the warnings, bestie, pay attention:

  • If $filename is not defined, the Param::Missing exception is raised.
  • If the path does not point to a existing file, the File::NotFound exception is raised.
  • If the file could not be opened, the File::Open exception is raised.

πŸ“ Write($path)

Write the configuration into the file specified by path $path. πŸ’–

πŸ“ ToString()

Returns the string representation of the configuration file. πŸ¦‹


πŸ‘‘ PREREQUISITES πŸ‘‘

perl 5.008 (or later) is required, no exceptions (well, except the exception classes, lol). Besides perl, you must have the following:

  • RoPkg::Exceptions
  • Scalar::Util
  • English

🌈 SEE ALSO 🌈

  • RoPkg::Rsync::Atom
  • RoPkg::Rsync::ConfFile
  • RoPkg::Exceptions

πŸ’œ AUTHOR πŸ’œ

Subredu Manuel <diablo@iasi.roedu.net> β€” the icon, the legend, the moment. 🫢


πŸ“œ 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. πŸ’…


okay that's the whole page bestie, mwah πŸ˜­πŸ’– β€” this was perl v5.32.1, dated 2021-12-26, and yes we're obsessed with her. bye!! πŸŽ€βœ¨

πŸ“¦ where this page comes from