App-cpanminus
view release on metacpan or search on metacpan
lib/App/cpanminus/fatscript.pm view on Meta::CPAN
);
}
sub _vgt {
my($self,$l,$r) = @_;
$self->_vcmp($l,$r) > 0;
}
sub _vlt {
my($self,$l,$r) = @_;
$self->_vcmp($l,$r) < 0;
}
sub _vge {
my($self,$l,$r) = @_;
$self->_vcmp($l,$r) >= 0;
}
sub _vle {
my($self,$l,$r) = @_;
$self->_vcmp($l,$r) <= 0;
}
sub _vstring {
my($self,$n) = @_;
$n =~ s/^v// or die "Parse::PMFile::_vstring() called with invalid arg [$n]";
pack "U*", split /\./, $n;
}
# vv => visible vstring
sub _float2vv {
my($self,$n) = @_;
my($rev) = int($n);
$rev ||= 0;
my($mantissa) = $n =~ /\.(\d{1,12})/; # limit to 12 digits to limit
# architecture influence
$mantissa ||= 0;
$mantissa .= "0" while length($mantissa)%3;
my $ret = "v" . $rev;
while ($mantissa) {
$mantissa =~ s/(\d{1,3})// or
die "Panic: length>0 but not a digit? mantissa[$mantissa]";
$ret .= ".".int($1);
}
# warn "n[$n]ret[$ret]";
$ret =~ s/(\.0)+/.0/; # v1.0.0 => v1.0
$ret;
}
sub _readable {
my($self,$n) = @_;
$n =~ /^([\w\-\+\.]+)/;
return $1 if defined $1 && length($1)>0;
# if the first user reaches version v43, he will be treated as "+".
# We'll have to decide about a new rule here then, depending on what
# will be the prevailing versioning behavior then.
if ($] < 5.006) { # or whenever v-strings were introduced
# we get them wrong anyway, whatever we do, because 5.005 will
# have already interpreted 0.2.4 to be "0.24". So even if he
# indexer sends us something like "v0.2.4" we compare wrongly.
# And if they say v1.2, then the old perl takes it as "v12"
$self->_verbose(9, "Suspicious version string seen [$n]\n");
return $n;
}
my $better = sprintf "v%vd", $n;
$self->_verbose(9, "n[$n] better[$better]");
return $better;
}
1;
__END__
=head1 NAME
Parse::PMFile - parses .pm file as PAUSE does
=head1 SYNOPSIS
use Parse::PMFile;
my $parser = Parse::PMFile->new($metadata, {VERBOSE => 1});
my $packages_info = $parser->parse($pmfile);
# if you need info about invalid versions
my ($packages_info, $errors) = $parser->parse($pmfile);
# to check permissions
my $parser = Parse::PMFile->new($metadata, {
USERID => 'ISHIGAKI',
PERMISSIONS => PAUSE::Permissions->new,
});
=head1 DESCRIPTION
The most of the code of this module is taken from the PAUSE code as of April 2013 almost verbatim. Thus, the heart of this module should be quite stable. However, I made it not to use pipe ("-|") as well as I stripped database-related code. If you ...
This module doesn't provide features to extract a distribution or parse meta files intentionally.
=head1 METHODS
=head2 new
creates an object. You can also pass a hashref taken from META.yml etc, and an optional hashref. Options are:
=over 4
=item ALLOW_DEV_VERSION
Parse::PMFile usually ignores a version with an underscore as PAUSE does (because it's for a developer release, and should not be indexed). Set this option to true if you happen to need to keep such a version for better analysis.
=item VERBOSE
Set this to true if you need to know some details.
=item FORK
( run in 1.317 second using v1.01-cache-2.11-cpan-39bf76dae61 )