- fixed rt.cpan.org#63487 documentation error.

- fixed rt.cpan.org#61302, now croak if the config file
          parameter is a directory and directory include is not
          turned on.

        - fixed rt.cpan.org#60429 META.yml typo

        - added new option -AllowSingleQuoteInterpolation, which
          turns on interpolation for variables inside single quotes.

        - added test case for the new option



git-svn-id: http://dev.catalyst.perl.org/repos/Config-General/trunk@91 be1acefe-a474-0410-9a34-9b3221f2030f
This commit is contained in:
Thomas von Dein
2010-12-01 10:42:39 +00:00
parent 643107150c
commit 90f215d98c
6 changed files with 48 additions and 14 deletions

View File

@@ -1,3 +1,18 @@
2.50
- fixed rt.cpan.org#63487 documentation error.
- fixed rt.cpan.org#61302, now croak if the config file
parameter is a directory and directory include is not
turned on.
- fixed rt.cpan.org#60429 META.yml typo
- added new option -AllowSingleQuoteInterpolation, which
turns on interpolation for variables inside single quotes.
- added test case for the new option
2.49 2.49
- fixed rt.cpan.org#56532, '#' missed during fix for - fixed rt.cpan.org#56532, '#' missed during fix for
56370 in 2.45. 56370 in 2.45.

View File

@@ -32,7 +32,7 @@ use Carp::Heavy;
use Carp; use Carp;
use Exporter; use Exporter;
$Config::General::VERSION = 2.49; $Config::General::VERSION = "2.50";
use vars qw(@ISA @EXPORT_OK); use vars qw(@ISA @EXPORT_OK);
use base qw(Exporter); use base qw(Exporter);
@@ -87,7 +87,8 @@ sub new {
files => {}, # which files we have read, if any files => {}, # which files we have read, if any
UTF8 => 0, UTF8 => 0,
SaveSorted => 0, SaveSorted => 0,
ForceArray => 0 # force single value array if value enclosed in [] ForceArray => 0, # force single value array if value enclosed in []
AllowSingleQuoteInterpolation => 0
}; };
# create the class instance # create the class instance
@@ -495,6 +496,9 @@ sub _open {
} }
} }
} }
elsif (-d $configfile) {
croak "Config::General: config file argument is a directory, expecting a file!\n";
}
elsif (-e _) { elsif (-e _) {
if (exists $this->{files}->{$configfile} and not $this->{IncludeAgain}) { if (exists $this->{files}->{$configfile} and not $this->{IncludeAgain}) {
# do not read the same file twice, just return # do not read the same file twice, just return
@@ -1742,6 +1746,11 @@ configs.
This implies B<-InterPolateVars>. This implies B<-InterPolateVars>.
=item B<-AllowSingleQuoteInterpolation>
By default variables inside single quotes will not be interpolated. If
you turn on this option, they will be interpolated as well.
=item B<-ExtendedAccess> =item B<-ExtendedAccess>
If set to a true value, you can use object oriented (extended) methods to If set to a true value, you can use object oriented (extended) methods to
@@ -1835,7 +1844,7 @@ you will get such an error message from the parser:
This is caused by the fact that the config chunk below will be This is caused by the fact that the config chunk below will be
internally converted to: internally converted to:
<Directory><Directory /> <Directory></Directory>
Index index.awk Index index.awk
</Directory> </Directory>
@@ -2532,7 +2541,7 @@ Thomas Linden <tlinden |AT| cpan.org>
=head1 VERSION =head1 VERSION
2.49 2.50
=cut =cut

View File

@@ -8,7 +8,7 @@
# #
package Config::General::Interpolated; package Config::General::Interpolated;
$Config::General::Interpolated::VERSION = "2.13"; $Config::General::Interpolated::VERSION = "2.14";
use strict; use strict;
use Carp; use Carp;
@@ -72,11 +72,14 @@ sub _interpolate {
# which will be replaced after interpolation with the original quotes # which will be replaced after interpolation with the original quotes
# fixes bug rt#35766 # fixes bug rt#35766
my %quotes; my %quotes;
$value =~ s/(\'[^\']+?\')/
my $key = "QUOTE" . ($quote_counter++) . "QUOTE"; if(! $this->{AllowSingleQuoteInterpolation} ) {
$quotes{ $key } = $1; $value =~ s/(\'[^\']+?\')/
$key; my $key = "QUOTE" . ($quote_counter++) . "QUOTE";
/gex; $quotes{ $key } = $1;
$key;
/gex;
}
$value =~ s{$this->{regex}}{ $value =~ s{$this->{regex}}{
my $con = $1; my $con = $1;
@@ -347,7 +350,7 @@ See L<http://www.perl.com/perl/misc/Artistic.html>
=head1 VERSION =head1 VERSION
2.13 2.14
=cut =cut

View File

@@ -1,5 +1,5 @@
name: Config-General name: Config-General
version: 2.45 version: 2.50
version_from: General.pm version_from: General.pm
installdirs: site installdirs: site
requires: requires:

2
README
View File

@@ -104,4 +104,4 @@ AUTHOR
VERSION VERSION
2.45 2.50

View File

@@ -8,7 +8,7 @@
use Data::Dumper; use Data::Dumper;
use Test::More tests => 67; use Test::More tests => 68;
#use Test::More qw(no_plan); #use Test::More qw(no_plan);
# ahem, we deliver the test code with a local copy of # ahem, we deliver the test code with a local copy of
@@ -723,5 +723,12 @@ $cfg52 = new Config::General( -ConfigFile => "t/cfg.52.out", -ForceArray => 1);
my %hash52new = $cfg52->getall(); my %hash52new = $cfg52->getall();
is_deeply(\%hash52new, \%hash52, "check -ForceArray single value arrays during save()"); is_deeply(\%hash52new, \%hash52, "check -ForceArray single value arrays during save()");
my $cfg53 = new Config::General(-AllowSingleQuoteInterpolation => 1, -String => "got = 1\nhave = '\$got'", -InterPolateVars => 1 );
my %hash53 = $cfg53->getall();
is($hash53{have}, "'1'", "check -AllowSingleQuoteInterpolation");
# Make sure no warnings were seen during the test. # Make sure no warnings were seen during the test.
ok( !@WARNINGS_FOUND, "No unexpected warnings seen" ); ok( !@WARNINGS_FOUND, "No unexpected warnings seen" );