mirror of
https://codeberg.org/scip/Config-General.git
synced 2025-12-16 20:21:01 +01:00
2.02 - added patch by Jens Heunemann, which allows to use
whitespaces in option names.
- changed the save() calls in the test script (t/run.t)
to save_file()
- removed new() from ::Interpolated and ::Extended.
This may break existing code (they will need to
move to the flags of Config::General::new() ), but
this decision must be made. The problem was that
both the old way of directly using the subclasses
and the enw way did not work together. So, now
subclasses are only method holders and used by
Config::General on request. Direct use of subclasses
is prohibited. (you receive a warning if you do).
git-svn-id: http://dev.catalyst.perl.org/repos/Config-General/trunk@28 be1acefe-a474-0410-9a34-9b3221f2030f
This commit is contained in:
@@ -24,7 +24,13 @@ use vars qw(@ISA @EXPORT);
|
||||
use strict;
|
||||
|
||||
|
||||
$Config::General::Extended::VERSION = "1.6";
|
||||
$Config::General::Extended::VERSION = "1.7";
|
||||
|
||||
|
||||
sub new {
|
||||
croak "Deprecated method Config::General::Extended::new() called.\n"
|
||||
."Use Config::General::new() instead and set the -ExtendedAccess flag.\n";
|
||||
}
|
||||
|
||||
|
||||
sub obj {
|
||||
@@ -36,14 +42,14 @@ sub obj {
|
||||
my($this, $key) = @_;
|
||||
if (exists $this->{config}->{$key}) {
|
||||
if (!$this->{config}->{$key}) {
|
||||
return $this->new( () ); # empty object!
|
||||
return $this->SUPER::new( -ExtendedAccess => 1, -ConfigHash => {} ); # empty object!
|
||||
}
|
||||
else {
|
||||
return $this->new( $this->{config}->{$key} );
|
||||
return $this->SUPER::new( -ExtendedAccess => 1, -ConfigHash => $this->{config}->{$key} );
|
||||
}
|
||||
}
|
||||
else {
|
||||
return $this->new( $this->{config} );
|
||||
return $this->SUPER::new( -ExtendedAccess => 1, -ConfigHash => $this->{config} );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -263,7 +269,7 @@ Config::General::Extended - Extended access to Config files
|
||||
use Config::General;
|
||||
|
||||
$conf = new Config::General(
|
||||
-file => 'configfile',
|
||||
-ConfigFile => 'configfile',
|
||||
-ExtendedAccess => 1
|
||||
);
|
||||
|
||||
@@ -490,7 +496,7 @@ Thomas Linden <tom@daemon.de>
|
||||
|
||||
=head1 VERSION
|
||||
|
||||
1.6
|
||||
1.7
|
||||
|
||||
=cut
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
package Config::General::Interpolated;
|
||||
$Config::General::Interpolated::VERSION = "1.1";
|
||||
$Config::General::Interpolated::VERSION = "1.3";
|
||||
|
||||
use strict;
|
||||
use Carp;
|
||||
@@ -17,14 +17,9 @@ sub new {
|
||||
# overwrite new() with our own version
|
||||
# and call the parent class new()
|
||||
#
|
||||
my $class = shift;
|
||||
my $self = $class->SUPER::new(@_);
|
||||
|
||||
$self->{regex} = $self->_set_regex();
|
||||
|
||||
$self->{config} = $self->_vars($self->{config}, {});
|
||||
|
||||
return $self;
|
||||
croak "Deprecated method Config::General::Interpolated::new() called.\n"
|
||||
."Use Config::General::new() instead and set the -InterPolateVars flag.\n";
|
||||
}
|
||||
|
||||
|
||||
@@ -62,7 +57,7 @@ sub _vars {
|
||||
# collect values that don't need to be substituted first
|
||||
while (my ($key, $value) = each %{$config}) {
|
||||
$varstack{$key} = $value
|
||||
unless ref($value) or $value =~ $this->{regex};
|
||||
unless ref($value) or $value =~ /$this->{regex}/;
|
||||
}
|
||||
|
||||
my $sub_interpolate = sub {
|
||||
@@ -102,8 +97,10 @@ sub _vars {
|
||||
# traverse the hierarchy part
|
||||
while (my ($key, $value) = each %{$config}) {
|
||||
# this is not a scalar recursive call to myself
|
||||
_vars($value, {%{$stack}, %varstack})
|
||||
if ref($value) eq 'HASH';
|
||||
if (ref($value) eq 'HASH') {
|
||||
# called via Gonfig::General procedural
|
||||
_vars($this, $value, {%{$stack}, %varstack});
|
||||
}
|
||||
}
|
||||
|
||||
return $config;
|
||||
@@ -123,7 +120,7 @@ Config::General::Interpolated - Parse variables within Config files
|
||||
|
||||
use Config::General;
|
||||
$conf = new Config::General(
|
||||
-file => 'configfile',
|
||||
-CinfigFile => 'configfile',
|
||||
-InterPolateVars => 1
|
||||
);
|
||||
|
||||
@@ -213,7 +210,7 @@ See L<http://www.perl.com/perl/misc/Artistic.html>
|
||||
|
||||
=head1 VERSION
|
||||
|
||||
This document describes version 1.1 of B<Config::General::Interpolated>.
|
||||
1.3
|
||||
|
||||
=cut
|
||||
|
||||
|
||||
Reference in New Issue
Block a user