diff --git a/Changelog b/Changelog index a403025..aa8d4a7 100644 --- a/Changelog +++ b/Changelog @@ -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 - fixed rt.cpan.org#56532, '#' missed during fix for 56370 in 2.45. diff --git a/General.pm b/General.pm index 896d06a..c3077a6 100644 --- a/General.pm +++ b/General.pm @@ -32,7 +32,7 @@ use Carp::Heavy; use Carp; use Exporter; -$Config::General::VERSION = 2.49; +$Config::General::VERSION = "2.50"; use vars qw(@ISA @EXPORT_OK); use base qw(Exporter); @@ -87,7 +87,8 @@ sub new { files => {}, # which files we have read, if any UTF8 => 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 @@ -495,6 +496,9 @@ sub _open { } } } + elsif (-d $configfile) { + croak "Config::General: config file argument is a directory, expecting a file!\n"; + } elsif (-e _) { if (exists $this->{files}->{$configfile} and not $this->{IncludeAgain}) { # do not read the same file twice, just return @@ -1742,6 +1746,11 @@ configs. 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> 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 internally converted to: - + Index index.awk @@ -2532,7 +2541,7 @@ Thomas Linden =head1 VERSION -2.49 +2.50 =cut diff --git a/General/Interpolated.pm b/General/Interpolated.pm index aaef6b7..e259964 100644 --- a/General/Interpolated.pm +++ b/General/Interpolated.pm @@ -8,7 +8,7 @@ # package Config::General::Interpolated; -$Config::General::Interpolated::VERSION = "2.13"; +$Config::General::Interpolated::VERSION = "2.14"; use strict; use Carp; @@ -72,11 +72,14 @@ sub _interpolate { # which will be replaced after interpolation with the original quotes # fixes bug rt#35766 my %quotes; - $value =~ s/(\'[^\']+?\')/ - my $key = "QUOTE" . ($quote_counter++) . "QUOTE"; - $quotes{ $key } = $1; - $key; - /gex; + + if(! $this->{AllowSingleQuoteInterpolation} ) { + $value =~ s/(\'[^\']+?\')/ + my $key = "QUOTE" . ($quote_counter++) . "QUOTE"; + $quotes{ $key } = $1; + $key; + /gex; + } $value =~ s{$this->{regex}}{ my $con = $1; @@ -347,7 +350,7 @@ See L =head1 VERSION -2.13 +2.14 =cut diff --git a/META.yml b/META.yml index 5fd4b45..08c5190 100644 --- a/META.yml +++ b/META.yml @@ -1,5 +1,5 @@ name: Config-General -version: 2.45 +version: 2.50 version_from: General.pm installdirs: site requires: diff --git a/README b/README index 291077b..ea5354a 100644 --- a/README +++ b/README @@ -104,4 +104,4 @@ AUTHOR VERSION - 2.45 + 2.50 diff --git a/t/run.t b/t/run.t index 1d04f88..0217d81 100644 --- a/t/run.t +++ b/t/run.t @@ -8,7 +8,7 @@ use Data::Dumper; -use Test::More tests => 67; +use Test::More tests => 68; #use Test::More qw(no_plan); # 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(); 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. ok( !@WARNINGS_FOUND, "No unexpected warnings seen" ); + +