Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Respect class/role if the PAUSE finds a few modules are used in the pacakge file #447

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 52 additions & 3 deletions lib/PAUSE/pmfile.pm
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,7 @@ sub packages_per_pmfile {
my $inpod = 0;

my $checked_bom;
my $package_or_class = 'package';
PLINE: while (<$fh>) {
chomp;
my($pline) = $_;
Expand All @@ -225,15 +226,38 @@ sub packages_per_pmfile {
last PLINE;
}

=pod
# hide in the pod block until 'class' is added to a version bundle
if ($pline =~ /^[\s\{;]*use\s(+v?5\.[0-9]+)/) {
my $version = $1;
my $version_bundle_for_class = version->parse("v5.xx.xx");
if (eval { version->parse($version) >= $version_bundle_for_class) {
$package_or_class = 'package|class|role';
}
next PLINE;
}
=cut

# use feature 'class'; enables class (and role, though not implemented yet)
if ($pline =~ /^[\s\{;]*use\s+(?:feature|experimental)\s+[^;]+\b(?:class|all)[^;]*;/) {
$package_or_class = 'package|class';
}
if ($pline =~ /^[\s\{;]*use\s+(?:Feature::Compat::Class)[^;]*;/) {
$package_or_class = 'package|class';
}
# Object::Pad is special-cased; let's ignore other modules that are too old or less known
if ($pline =~ /^[\s\{;]*use\s+(?:Object::Pad)[^;]*;/) {
$package_or_class = 'package|class|role';
}

my $pkg;
my $strict_version;

if (
$pline =~ m{
^
[\s\{;]*
package
\s+
\b(?:$package_or_class)\s+
([\w\:\']+)
\s*
(?: $ | [\}\;] | \{ | \s+($version::STRICT) )
Expand Down Expand Up @@ -333,13 +357,38 @@ sub packages_per_pmfile {
local $/ = "\n";
open(FH,$parsefile) or die "Could not open '$parsefile': $!";
my $inpod = 0;
my $package_or_class = 'package';
while (<FH>) {
$inpod = /^=(?!cut)/ ? 1 : /^=cut/ ? 0 : $inpod;
next if $inpod || /^\s*#/;
last if /^__(?:END|DATA)__\b/; # fails on quoted __END__ but this is rare -> __END__ in the middle of a line is rarer
chop;

if (my ($ver) = /package \s+ \S+ \s+ (\S+) \s* [;{]/x) {
=pod
# hide in the pod block until 'class' is added to a version bundle
if (/^[\s\{;]*use\s(+v?5\.[0-9]+)/) {
my $version = $1;
my $version_bundle_for_class = version->parse("v5.xx.xx");
if (eval { version->parse($version) >= $version_bundle_for_class) {
$package_or_class = 'package|class|role';
}
next;
}
=cut

# use feature 'class'; enables class (and role, though not implemented yet)
if (/^[\s\{;]*use\s+(?:feature|experimental)\s+[^;]+\b(?:class|all)[^;]*;/) {
$package_or_class = 'package|class';
}
if (/^[\s\{;]*use\s+(?:Feature::Compat::Class)[^;]*;/) {
$package_or_class = 'package|class';
}
# Object::Pad is special-cased; let's ignore other modules that are too old or less known
if (/^[\s\{;]*use\s+(?:Object::Pad)[^;]*;/) {
$package_or_class = 'package|class|role';
}

if (my ($ver) = /^[\s\{;]*(?:$package_or_class) \s+ \S+ \s+ (\S+) \s* [;{]/x) {
# XXX: should handle this better if version is bogus -- rjbs,
# 2014-03-16
return $ver if version::is_lax($ver);
Expand Down
Loading
Loading