i 1.24: - AllowMultiOptions printed out the value and not the

option itself, if more than one of this particular
           option occured.
         - added -UseApacheInclude feature, contributed by
           Thomas Klausner <domm@zsi.at>
         - fixed bug with multiple options stuff, which did not
           work with blocks or named blocks. Pointed out by
           Thomas Klausner <domm@zsi.at>, who meant it being
           feature request, but in fact it was a bug (IMHO).
	 - Config::General does now contain also it's OO-sister
	   Config::General::Extended, which is from now on
 	   no more available as an extra module, because it
	   lived a shadowy existence.
	 - finally(!) created a Changelog file (this one, yes).


git-svn-id: http://dev.catalyst.perl.org/repos/Config-General/trunk@12 be1acefe-a474-0410-9a34-9b3221f2030f
This commit is contained in:
Thomas von Dein
2009-10-10 16:11:25 +00:00
parent fc54974d01
commit 95195c0038
7 changed files with 860 additions and 60 deletions

83
t/run.t
View File

@@ -1,15 +1,18 @@
#
# testscript for Conf.pm by Thomas Linden
# testscript for Config::General Classes by Thomas Linden
#
# needs to be invoked using the command "make test" from
# the Conf.pm source directory.
# Under normal circumstances every test should run.
# the Config::General source directory.
#
# Under normal circumstances every test should succeed.
BEGIN { $| = 1; print "1..8\n";}
BEGIN { $| = 1; print "1..15\n";}
use lib "blib/lib";
use Config::General;
use Config::General::Extended;
use Data::Dumper;
print "ok\n";
print STDERR "\n1 .. ok # loading Config::General\n";
print STDERR "\n1 .. ok # loading Config::General and Config::General::Extended\n";
foreach (2..7) {
&p("t/cfg." . $_, $_);
@@ -37,6 +40,76 @@ else {
}
############## Extended Tests #################
$conf = new Config::General::Extended("t/test.rc");
print "ok\n";
print STDERR "9 .. ok # Creating a new object from config file\n";
# now test the new notation of new()
my $conf2 = new Config::General::Extended(
-file => "t/test.rc",
-AllowMultiOptions => "yes"
);
print "ok\n";
print STDERR "10 .. ok # Creating a new object using the hash parameter way\n";
my $domain = $conf->obj("domain");
print "ok\n";
print STDERR "11 .. ok # Creating a new object from a block\n";
my $addr = $domain->obj("bar.de");
print "ok\n";
print STDERR "12 .. ok # Creating a new object from a sub block\n";
my @keys = $conf->keys("domain");
print "ok\n";
print STDERR "13 .. ok # Getting values from the object\n";
# test various OO methods
if ($conf->is_hash("domain")) {
my $domains = $conf->obj("domain");
foreach my $domain ($conf->keys("domain")) {
my $domain_obj = $domains->obj($domain);
foreach my $address ($domains->keys($domain)) {
my $blah = $domain_obj->value($address);
}
}
}
print "ok\n";
print STDERR "14 .. ok # Using keys() and values() \n";
# test AUTOLOAD methods
my $conf3 = new Config::General::Extended( { name => "Moser", prename => "Hannes"}
);
my $n = $conf3->name;
my $p = $conf3->prename;
$conf3->name("Meier");
$conf3->prename("Max");
$conf3->save("t/test.cfg");
print "ok\n";
print STDERR "15 .. ok # Using AUTOLOAD methods\n";
sub p {
my($cfg, $t) = @_;
open T, "<$cfg";

90
t/test.rc Normal file
View File

@@ -0,0 +1,90 @@
/*
* Beispiel .redirect Datei.
*
* Wenn diese Datei nicht im $HOME des
* jeweiligen Benutzers vorhanden ist,
* oder wenn die vorhandene Datei aus
* irgendeinem Grund ung<6E>ltig ist(Syntax)
* dann wird per Default alles an @domain
* zum Benutzer weitergeleitet.
*
* Syntax:
* Domain Bl<42>cke beginnen mit <domain name> und enden
* mit </domain> (equivalent zu apache config).
* Als Kommentare sind # sowie C-Style erlaubt(so
* wie dieser hier).
* N<>heres zum <domain ...> Block siehe unten.
*
* Im <var> Block kann man Variablen definieren, auf
* die man dann innerhalb der <domain...> Bl<42>cke zu-
* greifen kann (siehe <var> sample!)
*
*
* Im <list name> Block kann man Mailinglisten einrichten
* allerdings rudiment<6E>r, d.h. es sind eigentlich nur
* Verteiler, aber immerhin. Die entsprechende Adresse
* muss im dazugeh<65>rigen <domain..> Block definiert sein.
*
* Angegebene Emailadressen werden (zumindest im Moment)
* nicht <20>berpr<70>ft, also 1:1 <20>bernommen, also Sorgfalt
* walten lassen.
*
* Fragen/Kommentare/Kritik/Flames/Mecker an:
* Thomas Linden <tom@daemon.de>
*
*/
/*
*********************************************************************
* Hier kann man Variablen definieren und sp<73>ter mittels
* $variablenname verwenden.
*********************************************************************
*/
<var>
USER scip # via $USER verwendbar
</var>
host manna
host gorky
/*
*********************************************************************
* F<>r jede Domain muss ein <domain name> Block vorhanden sein
*********************************************************************
*/
<domain bar.de>
foo max@nasa.gov # foo@bar.de nach max@nasa.gov
coderz %coderz # coderz@bar.de ist ein Verteiler, der
# in <list coderz> definiert ist.
@ $USER # alles andere an "scip" schicken.
# Wenn nicht angegeben, kommen unbekannte
# Adressen an den Absender zur<75>ck, z.B.
# gibtsnet@bar.de w<>rde "Unknown User" ver-
# ursachen!
</domain>
/*
*********************************************************************
* Definition einer "Mailingliste", g<>ltige Empf<70>nger m<>ssen mit
* dem Parameter "rcpt" definiert werden. <list> Bl<42>cke sind Domain-
* unabh<62>ngig, d.h. sie m<>ssen einen eindeutigen Namen haben.
*********************************************************************
*/
<list coderz>
rcpt solaar.designer@packetstorm.org
rcpt $USER
rcpt machine@star.wars.de
</list>