From: Steve Hay Date: Fri, 19 Dec 2008 14:38:54 +0000 (+0000) Subject: Subject: [PATCH] Update Module::Load::Conditional to 0.28 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=9b31c40c5f3f020eae721bb863fc9731399c4f70;p=p5sagit%2Fp5-mst-13.2.git Subject: [PATCH] Update Module::Load::Conditional to 0.28 From: "Jos I. Boumans" Date: Wed, 17 Dec 2008 14:24:23 +0100 Message-Id: --- diff --git a/lib/Module/Load/Conditional.pm b/lib/Module/Load/Conditional.pm index 90f9d6c..4fba341 100644 --- a/lib/Module/Load/Conditional.pm +++ b/lib/Module/Load/Conditional.pm @@ -18,7 +18,7 @@ BEGIN { $FIND_VERSION $ERROR $CHECK_INC_HASH]; use Exporter; @ISA = qw[Exporter]; - $VERSION = '0.26'; + $VERSION = '0.28'; $VERBOSE = 0; $FIND_VERSION = 1; $CHECK_INC_HASH = 0; @@ -116,6 +116,11 @@ to find the file: Full path to the file that contains the module +=item dir + +Directory, or more exact the C<@INC> entry, where the module was +loaded from. + =item version The version number of the installed module - this will be C if @@ -226,6 +231,9 @@ sub check_install { } } + ### store the directory we found the file in + $href->{dir} = $dir; + ### files need to be in unix format under vms, ### or they might be loaded twice $href->{file} = ON_VMS @@ -236,18 +244,20 @@ sub check_install { if( $FIND_VERSION ) { my $in_pod = 0; - while (local $_ = <$fh> ) { + while ( my $line = <$fh> ) { ### stolen from EU::MM_Unix->parse_version to address ### #24062: "Problem with CPANPLUS 0.076 misidentifying ### versions after installing Text::NSP 1.03" where a ### VERSION mentioned in the POD was found before ### the real $VERSION declaration. - $in_pod = /^=(?!cut)/ ? 1 : /^=cut/ ? 0 : $in_pod; + $in_pod = $line =~ /^=(?!cut)/ ? 1 : + $line =~ /^=cut/ ? 0 : + $in_pod; next if $in_pod; ### try to find a version declaration in this string. - my $ver = __PACKAGE__->_parse_version( $_ ); + my $ver = __PACKAGE__->_parse_version( $line ); if( defined $ver ) { $href->{version} = $ver; diff --git a/lib/Module/Load/Conditional/t/01_Module_Load_Conditional.t b/lib/Module/Load/Conditional/t/01_Module_Load_Conditional.t index 01d427a..dbd5ecd 100644 --- a/lib/Module/Load/Conditional/t/01_Module_Load_Conditional.t +++ b/lib/Module/Load/Conditional/t/01_Module_Load_Conditional.t @@ -20,8 +20,8 @@ use Test::More 'no_plan'; use constant ON_VMS => $^O eq 'VMS'; -use lib "$FindBin::Bin/../lib"; -use lib "$FindBin::Bin/to_load"; +use lib File::Spec->catdir($FindBin::Bin, qw[.. lib] ); +use lib File::Spec->catdir($FindBin::Bin, q[to_load] ); use_ok( 'Module::Load::Conditional' ); @@ -46,6 +46,12 @@ use_ok( 'Module::Load::Conditional' ); ok( $rv->{uptodate}, q[Verify self] ); is( $rv->{version}, $Module::Load::Conditional::VERSION, q[ Found proper version] ); + ok( $rv->{dir}, q[ Found directory information] ); + + { my $dir_re = qr/^$rv->{dir}/i; + like( $rv->{file}, $dir_re, + q[ Dir subset of file path] ); + } ### break up the specification my @rv_path = do { @@ -73,6 +79,8 @@ use_ok( 'Module::Load::Conditional' ); File::Spec::Unix->catfile(@rv_path), q[ Found proper file] ); + + }