Skip Menu |

This queue is for tickets about the Module-Metadata CPAN distribution.

Maintainer(s)' notes

Attention bug reporters: issues MUST include the version of Module::Metadata that you are running that exhibit the stated symptoms. thank you!

Report information
The Basics
Id: 77249
Status: rejected
Priority: 0/
Queue: Module-Metadata

People
Owner: Nobody in particular
Requestors: thaljef [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: Normal
Broken in: 1.000009
Fixed in: (no value)



Subject: Look for packages in *.pm.PL files, and inside __DATA__ section
PAUSE scans *.pm.PL files as possible sources of packages, but Module::Metadata does not. Also, PAUSE looks for package declarations inside the __DATA__ section when scanning a .pm.PL file. A good example of this is the common::sense module, which PAUSE will index but Module::Metadata will not. I can't really say that PAUSE's behavior is the "right" one. Personally, I think the burden for edge cases like this falls upon the module author to declare the "provides" in the META. But aside from that, PAUSE does give a more satisfactory answer in this situation. So perhaps Module::Metadata should do the same. A patch (with tests) is attached. -Jeff
Subject: Module-Metadata-1.000009.patch
diff -Naur Module-Metadata-1.000009/lib/Module/Metadata.pm Module-Metadata-1.000009-mine/lib/Module/Metadata.pm --- Module-Metadata-1.000009/lib/Module/Metadata.pm 2012-02-08 09:15:07.000000000 -0800 +++ Module-Metadata-1.000009-mine/lib/Module/Metadata.pm 2012-05-16 12:21:09.000000000 -0700 @@ -209,7 +209,7 @@ } else { find( { wanted => sub { - push @files, $_ if -f $_ && /\.pm$/; + push @files, $_ if -f $_ && /\.pm(?:\.PL)?$/; }, no_chdir => 1, }, $dir ); @@ -459,7 +459,9 @@ $in_pod = ($line =~ /^=(?!cut)/) ? 1 : ($line =~ /^=cut/) ? 0 : $in_pod; # Would be nice if we could also check $in_string or something too - last if !$in_pod && $line =~ /^__(?:DATA|END)__$/; + # Note: *.PL files could have code after the __DATA__ as well + last if !$in_pod && $line =~ /^__(?:DATA|END)__$/ + && $self->{filename} !~ /\.PL$/; if ( $in_pod || $line =~ /^=cut/ ) { diff -Naur Module-Metadata-1.000009/t/metadata.t Module-Metadata-1.000009-mine/t/metadata.t --- Module-Metadata-1.000009/t/metadata.t 2012-02-08 09:15:06.000000000 -0800 +++ Module-Metadata-1.000009-mine/t/metadata.t 2012-05-16 12:46:25.000000000 -0700 @@ -203,7 +203,7 @@ ); my %modules = reverse @modules; -plan tests => 42 + 2 * keys( %modules ); +plan tests => 43 + 2 * keys( %modules ); require_ok('Module::Metadata'); @@ -582,3 +582,41 @@ is_deeply( $got_provides, $exp_provides, "provides()" ) or diag explain $got_provides; } + +#------------------------------------------------------------------------------ + +{ + + # revert to pristine state + $dist->regen( clean => 1 ); + + # Create a pm.PL file with the package inside the __DATA__ + $dist->add_file( 'Simple.pm.PL', <<'---' ); +# No code here +__DATA__ +package Simple::InData; +$VERSION = '1.23'; +--- + + $dist->regen; + + my $got_pvfd = Module::Metadata->package_versions_from_directory($dist->dirname); + my $exp_pvfd = { + 'Simple' => { + 'file' => 'lib/Simple.pm', + 'version' => '0.01' + }, + 'Simple::Ex' => { + 'file' => 'lib/Simple.pm', + 'version' => '0.02' + }, + 'Simple::InData' => { + 'file' => 'Simple.pm.PL', + 'version' => '1.23' + } + }; + + + is_deeply( $got_pvfd, $exp_pvfd, "package inside a __DATA__ section of a .PL file" ) + or diag explain $got_pvfd; +}
Hey guys- Any thoughts on the aforementioned patch? -Jeff
Subject: Re: [rt.cpan.org #77249] Look for packages in *.pm.PL files, and inside __DATA__ section
Date: Thu, 31 May 2012 14:53:22 -0400
To: bug-Module-Metadata [...] rt.cpan.org
From: David Golden <dagolden [...] cpan.org>
Show quoted text
> Any thoughts on the aforementioned patch?
I'm open to the idea, but not as a default behavior. If a "scan_DATA" (or alternate name) option were added to enable DATA scanning, I'd be fine with that. That allows the same *algorithm* to be applied to such a section, but only on demand. Likewise for scanning .pm.PL files in package_versions_from_directory() -- it should have an option to enable it. David P.S. Thank you for including a test with the patch! It's so rare to see that and incredibly helpful of you.
I agree that such a feature should need to be enabled explictely. One the plus side, adding this will facilitate a possible port of PAUSE to Module::Metadata. Vincent
On Wed May 16 16:04:06 2012, THALJEF wrote: Show quoted text
> PAUSE scans *.pm.PL files as possible sources of packages, but > Module::Metadata does not. Also, PAUSE looks for package declarations > inside the __DATA__ section when scanning a .pm.PL file. A good example > of this is the common::sense module, which PAUSE will index but > Module::Metadata will not.
A patch is in the works to PAUSE to correct this bug. I concur that the upstream author should correctly set the provides key in their metafile - this will also be required for metacpan to be able to index it since they also don't wish to provide bugwards compatibility with the current PAUSE behaviour. As such, I'm closing this bug as rejected - thanks very much for your report, a doc patch to make clear why we don't index such broken dists would be very welcome.