2.01 - added -ConfigFile (in replace for -file) and

-ConfigHash (in replace for -hash) to get a consistent
	   parameter naming scheme. The old names are still
	   supported for backward compatibility, but no more
	   documented.

         - the parameter -BaseHash has been dropped because
	   -DefaultConfig already has the capabilities of
           defining a custom backing hash. The pod section for
	   -DefaultConfig has been enhanced to reflect this.

	 - README changed something. Removed the 'small' keyword,
	   because the module isn't really small anymore :-)
	   At least IMHO.


git-svn-id: http://dev.catalyst.perl.org/repos/Config-General/trunk@27 be1acefe-a474-0410-9a34-9b3221f2030f
This commit is contained in:
Thomas von Dein
2009-10-10 16:20:41 +00:00
parent 76502a240e
commit d50bae5acf
3 changed files with 47 additions and 43 deletions

View File

@@ -1,3 +1,18 @@
2.01 - added -ConfigFile (in replace for -file) and
-ConfigHash (in replace for -hash) to get a consistent
parameter naming scheme. The old names are still
supported for backward compatibility, but no more
documented.
- the parameter -BaseHash has been dropped because
-DefaultConfig already has the capabilities of
defining a custom backing hash. The pod section for
-DefaultConfig has been enhanced to reflect this.
- README changed something. Removed the 'small' keyword,
because the module isn't really small anymore :-)
At least IMHO.
2.00 - fixed a bug in the ::Extended::keys() method, which
caused a beloved "use of uninitialized ..." message.
Reported by Danial Pearce <danial@infoxchange.net.au>.

View File

@@ -17,7 +17,7 @@ use strict;
use Carp;
use Exporter;
$Config::General::VERSION = "2.00";
$Config::General::VERSION = "2.01";
use vars qw(@ISA @EXPORT);
@ISA = qw(Exporter);
@@ -53,8 +53,6 @@ sub new {
DefaultConfig => {},
BaseHash => {},
level => 1,
InterPolateVars => 0,
@@ -71,8 +69,10 @@ sub new {
if ($#param >= 1) {
# use of the new hash interface!
my %conf = @param;
$configfile = delete $conf{-file} if(exists $conf{-file});
$configfile = delete $conf{-hash} if(exists $conf{-hash});
$configfile = delete $conf{-file} if(exists $conf{-file}); # be backwards compatible
$configfile = delete $conf{-ConfigFile} if(exists $conf{-ConfigFile});
$configfile = delete $conf{-hash} if(exists $conf{-hash}); # be backwards compatible
$configfile = delete $conf{-ConfigHash} if(exists $conf{-ConfigHash});
@@ -104,15 +104,6 @@ sub new {
delete $conf{-BaseHash}; # ignore BaseHash if a default one was given
}
if (exists $conf{-BaseHash}) {
if ($conf{-BaseHash}) {
# we do not check for ref() output because the hash could
# be something we are not expecting, a tied hash for example
$self->{DefaultConfig} = $conf{-BaseHash};
}
delete $conf{-BaseHash};
}
# handle options which may either be true or false
# allowing "human" logic about what is true and what is not
foreach my $entry (keys %conf) {
@@ -853,19 +844,19 @@ the following keys set:
=over
=item B<-file>
=item B<-ConfigFile>
A filename or a filehandle, i.e.:
-file => "rcfile" or -file => \$FileHandle
-ConfigFile => "rcfile" or -ConfigFile => \$FileHandle
=item B<-hash>
=item B<-ConfigHash>
A hash reference, which will be used as the config, i.e.:
-hash => \%somehash
-ConfigHash => \%somehash
@@ -1032,6 +1023,14 @@ This can be a hash reference or a simple scalar (string) of a config. This
causes the module to preset the resulting config hash with the given values,
which allows you to set default values for particular config options directly.
This hash will be used as the 'backing hash' instead of a standard perl hash,
which allows you to affect the way, variable storing will be done. You could, for
example supply a tied hash, say Tie::DxHash, which preserves ordering of the
keys in the config (which a standard perl hash won't do). Or, you could supply
a hash tied to a DBM file to save the parsed variables to disk.
There are many more things to do in tie-land, see L<tie> to get some interesting
ideas.
=item B<-InterPolateVars>
@@ -1043,19 +1042,6 @@ input. See L<Config::General::Interpolated> for more informations.
If set to a true value, you can use object oriented (extended) methods to
access the parsed config. See L<Config::General::Extended> for more informations.
=item B<-BaseHash>
You can supply a reference to a 'hash' which will be used to store the parsed
contents of your config file instead of the default standard perl hash.
This is a way to affect the way, variable storing will be done. You could, for
example supply a tied hash, say Tie::DxHash, which preserves ordering of the
keys in the config (which a standard perl hash won't do). Or, you could supply
a hash tied to a DBM file to save the parsed variables to disk.
There are many more things to do in tie-land, see L<tie> to get some interesting
ideas.
=back
@@ -1580,7 +1566,7 @@ Thomas Linden <tom@daemon.de>
=head1 VERSION
2.00
2.01
=cut

25
README
View File

@@ -3,27 +3,30 @@ NAME
SYNOPSIS
use Config::General;
$conf = new Config::General("rcfile");
$conf = new Config::General(-ConfigFile => "myconfig.rc");
my %config = $conf->getall;
DESCRIPTION
This small module opens a config file and parses it's
contents for you. The new method requires one parameter
which needs to be a filename. The method getall returns a
hash which contains all options and it's associated values
of your config file.
This module opens a config file and parses it's contents
for you. After parsing the module returns a hash structure
which contains the representation of the config file.
The format of config files supported by Config::General is
inspired by the well known apache config format, in fact,
this module is 100% compatible to apache configs, but you
can also just use simple name/value pairs in your config
this module is 100% read-compatible to apache configs, but
you can also just use simple name/value pairs in your config
files.
In addition to the capabilities of an apache config file
In addition to the capabilities of a apache config file
it supports some enhancements such as here-documents, C-
style comments or multiline options.
style comments or multiline options. It is also possible to
save the config back to disk, which makes the module a
perfect backend for configuration interfaces.
It is possible to use variables in config files and there
exists also support for object oriented access to the
configuration.
INSTALLATION
@@ -65,4 +68,4 @@ AUTHOR
VERSION
1.36
2.01