Parse-PMFile-0.43/0000755000175000017500000000000013765001010013757 5ustar ishigakiishigakiParse-PMFile-0.43/README0000644000175000017500000000047112440006460014644 0ustar ishigakiishigakiParse-PMFile INSTALLATION To install this module, run the following commands: perl Makefile.PL make make test make install COPYRIGHT AND LICENSE Copyright (C) 2013 Kenichi Ishigaki This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. Parse-PMFile-0.43/lib/0000755000175000017500000000000013765001010014525 5ustar ishigakiishigakiParse-PMFile-0.43/lib/Parse/0000755000175000017500000000000013765001010015577 5ustar ishigakiishigakiParse-PMFile-0.43/lib/Parse/PMFile.pm0000644000175000017500000007431113765000664017275 0ustar ishigakiishigakipackage Parse::PMFile; sub __clean_eval { eval $_[0] } # needs to be here (RT#101273) use strict; use warnings; use Safe; use JSON::PP (); use Dumpvalue; use version (); use File::Spec (); our $VERSION = '0.43'; our $VERBOSE = 0; our $ALLOW_DEV_VERSION = 0; our $FORK = 0; our $UNSAFE = $] < 5.010000 ? 1 : 0; sub new { my ($class, $meta, $opts) = @_; bless {%{ $opts || {} }, META_CONTENT => $meta}, $class; } # from PAUSE::pmfile::examine_fio sub parse { my ($self, $pmfile) = @_; $pmfile =~ s|\\|/|g; my($filemtime) = (stat $pmfile)[9]; $self->{MTIME} = $filemtime; $self->{PMFILE} = $pmfile; unless ($self->_version_from_meta_ok) { my $version; unless (eval { $version = $self->_parse_version; 1 }) { $self->_verbose(1, "error with version in $pmfile: $@"); return; } $self->{VERSION} = $version; if ($self->{VERSION} =~ /^\{.*\}$/) { # JSON error message } elsif ($self->{VERSION} =~ /[_\s]/ && !$self->{ALLOW_DEV_VERSION} && !$ALLOW_DEV_VERSION){ # ignore developer releases and "You suck!" return; } } my($ppp) = $self->_packages_per_pmfile; my @keys_ppp = $self->_filter_ppps(sort keys %$ppp); $self->_verbose(1,"Will check keys_ppp[@keys_ppp]\n"); # # Immediately after each package (pmfile) examined contact # the database # my ($package, %errors); my %checked_in; DBPACK: foreach $package (@keys_ppp) { # this part is taken from PAUSE::package::examine_pkg # and PAUSE::package::_pkg_name_insane if ($package !~ /^\w[\w\:\']*\w?\z/ || $package !~ /\w\z/ || $package =~ /:/ && $package !~ /::/ || $package =~ /\w:\w/ || $package =~ /:::/ ){ $self->_verbose(1,"Package[$package] did not pass the ultimate sanity check"); delete $ppp->{$package}; next; } if ($self->{USERID} && $self->{PERMISSIONS} && !$self->_perm_check($package)) { delete $ppp->{$package}; next; } # Check that package name matches case of file name { my (undef, $module) = split m{/lib/}, $self->{PMFILE}, 2; if ($module) { $module =~ s{\.pm\z}{}; $module =~ s{/}{::}g; if (lc $module eq lc $package && $module ne $package) { # warn "/// $self->{PMFILE} vs. $module vs. $package\n"; $errors{$package} = { indexing_warning => "Capitalization of package ($package) does not match filename!", infile => $self->{PMFILE}, }; } } } my $pp = $ppp->{$package}; if ($pp->{version} && $pp->{version} =~ /^\{.*\}$/) { # JSON parser error my $err = JSON::PP::decode_json($pp->{version}); if ($err->{x_normalize}) { $errors{$package} = { normalize => $err->{version}, infile => $pp->{infile}, }; $pp->{version} = "undef"; } elsif ($err->{openerr}) { $pp->{version} = "undef"; $self->_verbose(1, qq{Parse::PMFile was not able to read the file. It issued the following error: C< $err->{r} >}, ); $errors{$package} = { open => $err->{r}, infile => $pp->{infile}, }; } else { $pp->{version} = "undef"; $self->_verbose(1, qq{Parse::PMFile was not able to parse the following line in that file: C< $err->{line} > Note: the indexer is running in a Safe compartement and cannot provide the full functionality of perl in the VERSION line. It is trying hard, but sometime it fails. As a workaround, please consider writing a META.yml that contains a 'provides' attribute or contact the CPAN admins to investigate (yet another) workaround against "Safe" limitations.)}, ); $errors{$package} = { parse_version => $err->{line}, infile => $err->{file}, }; } } # Sanity checks for ( $package, $pp->{version}, ) { if (!defined || /^\s*$/ || /\s/){ # for whatever reason I come here delete $ppp->{$package}; next; # don't screw up 02packages } } unless ($self->_version_ok($pp)) { $errors{$package} = { long_version => qq{Version string exceeds maximum allowed length of 16b: "$pp->{version}"}, infile => $pp->{infile}, }; next; } $checked_in{$package} = $ppp->{$package}; } # end foreach package return (wantarray && %errors) ? (\%checked_in, \%errors) : \%checked_in; } sub _version_ok { my ($self, $pp) = @_; return if length($pp->{version} || 0) > 16; return 1 } sub _perm_check { my ($self, $package) = @_; my $userid = $self->{USERID}; my $module = $self->{PERMISSIONS}->module_permissions($package); return 1 if !$module; # not listed yet return 1 if defined $module->m && $module->m eq $userid; return 1 if defined $module->f && $module->f eq $userid; return 1 if defined $module->c && grep {$_ eq $userid} @{$module->c}; return; } # from PAUSE::pmfile; sub _parse_version { my $self = shift; use strict; my $pmfile = $self->{PMFILE}; my $tmpfile = File::Spec->catfile(File::Spec->tmpdir, "ParsePMFile$$" . rand(1000)); my $pmcp = $pmfile; for ($pmcp) { s/([^\\](\\\\)*)@/$1\\@/g; # thanks to Raphael Manfredi for the # solution to escape @s and \ } my($v); { package main; # seems necessary # XXX: do we need to fork as PAUSE does? # or, is alarm() just fine? my $pid; if ($self->{FORK} || $FORK) { $pid = fork(); die "Can't fork: $!" unless defined $pid; } if ($pid) { waitpid($pid, 0); if (open my $fh, '<', $tmpfile) { $v = <$fh>; } } else { # XXX Limit Resources too my $comp; my $eval = qq{ local(\$^W) = 0; Parse::PMFile::_parse_version_safely("$pmcp"); }; unless ($self->{UNSAFE} || $UNSAFE) { $comp = Safe->new; $comp->permit("entereval"); # for MBARBON/Module-Info-0.30.tar.gz $comp->share("*Parse::PMFile::_parse_version_safely"); $comp->share("*version::new"); $comp->share("*version::numify"); $comp->share_from('main', ['*version::', '*charstar::', '*Exporter::', '*DynaLoader::']); $comp->share_from('version', ['&qv']); $comp->permit(":base_math"); # atan2 (Acme-Pi) # $comp->permit("require"); # no strict! $comp->deny(qw/enteriter iter unstack goto/); # minimum protection against Acme::BadExample } version->import('qv') if $self->{UNSAFE} || $UNSAFE; { no strict; $v = $comp ? $comp->reval($eval) : eval $eval; } if ($@){ # still in the child process, out of Safe::reval my $err = $@; # warn ">>>>>>>err[$err]<<<<<<<<"; if (ref $err) { if ($err->{line} =~ /([\$*])([\w\:\']*)\bVERSION\b.*?\=(.*)/) { local($^W) = 0; my ($sigil, $vstr) = ($1, $3); $self->_restore_overloaded_stuff(1) if $err->{line} =~ /use\s+version\b|version\->|qv\(/; $v = $comp ? $comp->reval($vstr) : eval $vstr; $v = $$v if $sigil eq '*' && ref $v; } if ($@ or !$v) { $self->_verbose(1, sprintf("reval failed: err[%s] for eval[%s]", JSON::PP::encode_json($err), $eval, )); $v = JSON::PP::encode_json($err); } } else { $v = JSON::PP::encode_json({ openerr => $err }); } } if (defined $v) { no warnings; $v = $v->numify if ref($v) =~ /^version(::vpp)?$/; } else { $v = ""; } if ($self->{FORK} || $FORK) { open my $fh, '>:utf8', $tmpfile; print $fh $v; exit 0; } else { utf8::encode($v); # undefine empty $v as if read from the tmpfile $v = undef if defined $v && !length $v; $comp->erase if ($comp); $self->_restore_overloaded_stuff; } } } unlink $tmpfile if ($self->{FORK} || $FORK) && -e $tmpfile; return $self->_normalize_version($v); } sub _restore_overloaded_stuff { my ($self, $used_version_in_safe) = @_; return if $self->{UNSAFE} || $UNSAFE; no strict 'refs'; no warnings 'redefine'; # version XS in CPAN my $restored; if ($INC{'version/vxs.pm'}) { *{'version::(""'} = \&version::vxs::stringify; *{'version::(0+'} = \&version::vxs::numify; *{'version::(cmp'} = \&version::vxs::VCMP; *{'version::(<=>'} = \&version::vxs::VCMP; *{'version::(bool'} = \&version::vxs::boolean; $restored = 1; } # version PP in CPAN if ($INC{'version/vpp.pm'}) { { package # hide from PAUSE charstar; overload->import; } if (!$used_version_in_safe) { package # hide from PAUSE version::vpp; overload->import; } unless ($restored) { *{'version::(""'} = \&version::vpp::stringify; *{'version::(0+'} = \&version::vpp::numify; *{'version::(cmp'} = \&version::vpp::vcmp; *{'version::(<=>'} = \&version::vpp::vcmp; *{'version::(bool'} = \&version::vpp::vbool; } *{'version::vpp::(""'} = \&version::vpp::stringify; *{'version::vpp::(0+'} = \&version::vpp::numify; *{'version::vpp::(cmp'} = \&version::vpp::vcmp; *{'version::vpp::(<=>'} = \&version::vpp::vcmp; *{'version::vpp::(bool'} = \&version::vpp::vbool; *{'charstar::(""'} = \&charstar::thischar; *{'charstar::(0+'} = \&charstar::thischar; *{'charstar::(++'} = \&charstar::increment; *{'charstar::(--'} = \&charstar::decrement; *{'charstar::(+'} = \&charstar::plus; *{'charstar::(-'} = \&charstar::minus; *{'charstar::(*'} = \&charstar::multiply; *{'charstar::(cmp'} = \&charstar::cmp; *{'charstar::(<=>'} = \&charstar::spaceship; *{'charstar::(bool'} = \&charstar::thischar; *{'charstar::(='} = \&charstar::clone; $restored = 1; } # version in core if (!$restored) { *{'version::(""'} = \&version::stringify; *{'version::(0+'} = \&version::numify; *{'version::(cmp'} = \&version::vcmp; *{'version::(<=>'} = \&version::vcmp; *{'version::(bool'} = \&version::boolean; } } # from PAUSE::pmfile; sub _packages_per_pmfile { my $self = shift; my $ppp = {}; my $pmfile = $self->{PMFILE}; my $filemtime = $self->{MTIME}; my $version = $self->{VERSION}; open my $fh, "<", "$pmfile" or return $ppp; local $/ = "\n"; my $inpod = 0; PLINE: while (<$fh>) { chomp; my($pline) = $_; $inpod = $pline =~ /^=(?!cut)/ ? 1 : $pline =~ /^=cut/ ? 0 : $inpod; next if $inpod; next if substr($pline,0,4) eq "=cut"; $pline =~ s/\#.*//; next if $pline =~ /^\s*$/; if ($pline =~ /^__(?:END|DATA)__\b/ and $pmfile !~ /\.PL$/ # PL files may well have code after __DATA__ ){ last PLINE; } my $pkg; my $strict_version; if ( $pline =~ m{ # (.*) # takes too much time if $pline is long #(? 128; #restriction $ppp->{$pkg}{parsed}++; $ppp->{$pkg}{infile} = $pmfile; if ($self->_simile($pmfile,$pkg)) { $ppp->{$pkg}{simile} = $pmfile; if ($self->_version_from_meta_ok) { my $provides = $self->{META_CONTENT}{provides}; if (exists $provides->{$pkg}) { if (defined $provides->{$pkg}{version}) { my $v = $provides->{$pkg}{version}; if ($v =~ /[_\s]/ && !$self->{ALLOW_DEV_VERSION} && !$ALLOW_DEV_VERSION){ # ignore developer releases and "You suck!" next PLINE; } unless (eval { $version = $self->_normalize_version($v); 1 }) { $self->_verbose(1, "error with version in $pmfile: $@"); next; } $ppp->{$pkg}{version} = $version; } else { $ppp->{$pkg}{version} = "undef"; } } } else { if (defined $strict_version){ $ppp->{$pkg}{version} = $strict_version ; } else { $ppp->{$pkg}{version} = defined $version ? $version : ""; } no warnings; if ($version eq 'undef') { $ppp->{$pkg}{version} = $version unless defined $ppp->{$pkg}{version}; } else { $ppp->{$pkg}{version} = $version if $version > $ppp->{$pkg}{version} || $version gt $ppp->{$pkg}{version}; } } } else { # not simile #### it comes later, it would be nonsense #### to set to "undef". MM_Unix gives us #### the best we can reasonably consider $ppp->{$pkg}{version} = $version unless defined $ppp->{$pkg}{version} && length($ppp->{$pkg}{version}); } $ppp->{$pkg}{filemtime} = $filemtime; } else { # $self->_verbose(2,"no pkg found"); } } close $fh; $ppp; } # from PAUSE::pmfile; { no strict; sub _parse_version_safely { my($parsefile) = @_; my $result; local *FH; local $/ = "\n"; open(FH,$parsefile) or die "Could not open '$parsefile': $!"; my $inpod = 0; while () { $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) { # XXX: should handle this better if version is bogus -- rjbs, # 2014-03-16 return $ver if version::is_lax($ver); } # next unless /\$(([\w\:\']*)\bVERSION)\b.*\=/; next unless /(?<=])\=(?![=>])/; my $current_parsed_line = $_; my $eval = qq{ package # ExtUtils::MakeMaker::_version; local $1$2; \$$2=undef; do { $_ }; \$$2 }; local $^W = 0; local $SIG{__WARN__} = sub {}; $result = __clean_eval($eval); # warn "current_parsed_line[$current_parsed_line]\$\@[$@]"; if ($@ or !defined $result){ die +{ eval => $eval, line => $current_parsed_line, file => $parsefile, err => $@, }; } last; } #; close FH; $result = "undef" unless defined $result; if ((ref $result) =~ /^version(?:::vpp)?\b/) { no warnings; $result = $result->numify; } return $result; } } # from PAUSE::pmfile; sub _filter_ppps { my($self,@ppps) = @_; my @res; # very similar code is in PAUSE::dist::filter_pms MANI: for my $ppp ( @ppps ) { if ($self->{META_CONTENT}){ my $no_index = $self->{META_CONTENT}{no_index} || $self->{META_CONTENT}{private}; # backward compat if (ref($no_index) eq 'HASH') { my %map = ( package => qr{\z}, namespace => qr{::}, ); for my $k (qw(package namespace)) { next unless my $v = $no_index->{$k}; my $rest = $map{$k}; if (ref $v eq "ARRAY") { for my $ve (@$v) { $ve =~ s|::$||; if ($ppp =~ /^$ve$rest/){ $self->_verbose(1,"Skipping ppp[$ppp] due to ve[$ve]"); next MANI; } else { $self->_verbose(1,"NOT skipping ppp[$ppp] due to ve[$ve]"); } } } else { $v =~ s|::$||; if ($ppp =~ /^$v$rest/){ $self->_verbose(1,"Skipping ppp[$ppp] due to v[$v]"); next MANI; } else { $self->_verbose(1,"NOT skipping ppp[$ppp] due to v[$v]"); } } } } else { $self->_verbose(1,"No keyword 'no_index' or 'private' in META_CONTENT"); } } else { # $self->_verbose(1,"no META_CONTENT"); # too noisy } push @res, $ppp; } $self->_verbose(1,"Result of filter_ppps: res[@res]"); @res; } # from PAUSE::pmfile; sub _simile { my($self,$file,$package) = @_; # MakeMaker gives them the chance to have the file Simple.pm in # this directory but have the package HTML::Simple in it. # Afaik, they wouldn't be able to do so with deeper nested packages $file =~ s|.*/||; $file =~ s|\.pm(?:\.PL)?||; my $ret = $package =~ m/\b\Q$file\E$/; $ret ||= 0; unless ($ret) { # Apache::mod_perl_guide stuffs it into Version.pm $ret = 1 if lc $file eq 'version'; } $self->_verbose(1,"Result of simile(): file[$file] package[$package] ret[$ret]\n"); $ret; } # from PAUSE::pmfile sub _normalize_version { my($self,$v) = @_; $v = "undef" unless defined $v; my $dv = Dumpvalue->new; my $sdv = $dv->stringify($v,1); # second argument prevents ticks $self->_verbose(1,"Result of normalize_version: sdv[$sdv]\n"); return $v if $v eq "undef"; return $v if $v =~ /^\{.*\}$/; # JSON object $v =~ s/^\s+//; $v =~ s/\s+\z//; if ($v =~ /_/) { # XXX should pass something like EDEVELOPERRELEASE up e.g. # SIXTEASE/XML-Entities-0.0306.tar.gz had nothing but one # such modules and the mesage was not helpful that "nothing # was found". return $v ; } if (!version::is_lax($v)) { return JSON::PP::encode_json({ x_normalize => 'version::is_lax failed', version => $v }); } # may warn "Integer overflow" my $vv = eval { no warnings; version->new($v)->numify }; if ($@) { # warn "$v: $@"; return JSON::PP::encode_json({ x_normalize => $@, version => $v }); # return "undef"; } if ($vv eq $v) { # the boring 3.14 } else { my $forced = $self->_force_numeric($v); if ($forced eq $vv) { } elsif ($forced =~ /^v(.+)/) { # rare case where a v1.0.23 slipped in (JANL/w3mir-1.0.10.tar.gz) no warnings; $vv = version->new($1)->numify; } else { # warn "Unequal forced[$forced] and vv[$vv]"; if ($forced == $vv) { # the trailing zeroes would cause unnecessary havoc $vv = $forced; } } } return $vv; } # from PAUSE::pmfile; sub _force_numeric { my($self,$v) = @_; $v = $self->_readable($v); if ( $v =~ /^(\+?)(\d*)(\.(\d*))?/ && # "$2$4" ne '' ( defined $2 && length $2 || defined $4 && length $4 ) ) { my $two = defined $2 ? $2 : ""; my $three = defined $3 ? $3 : ""; $v = "$two$three"; } # no else branch! We simply say, everything else is a string. $v; } # from PAUSE::dist sub _version_from_meta_ok { my($self) = @_; return $self->{VERSION_FROM_META_OK} if exists $self->{VERSION_FROM_META_OK}; my $c = $self->{META_CONTENT}; # If there's no provides hash, we can't get our module versions from the # provides hash! -- rjbs, 2012-03-31 return($self->{VERSION_FROM_META_OK} = 0) unless $c->{provides}; # Some versions of Module::Build geneated an empty provides hash. If we're # *not* looking at a Module::Build-generated metafile, then it's okay. my ($mb_v) = (defined $c->{generated_by} ? $c->{generated_by} : '') =~ /Module::Build version ([\d\.]+)/; return($self->{VERSION_FROM_META_OK} = 1) unless $mb_v; # ??? I don't know why this is here. return($self->{VERSION_FROM_META_OK} = 1) if $mb_v eq '0.250.0'; if ($mb_v >= 0.19 && $mb_v < 0.26 && ! keys %{$c->{provides}}) { # RSAVAGE/Javascript-SHA1-1.01.tgz had an empty provides hash. Ron # did not find the reason why this happened, but let's not go # overboard, 0.26 seems a good threshold from the statistics: there # are not many empty provides hashes from 0.26 up. return($self->{VERSION_FROM_META_OK} = 0); } # We're not in the suspect range of M::B versions. It's good to go. return($self->{VERSION_FROM_META_OK} = 1); } sub _verbose { my($self,$level,@what) = @_; warn @what if $level <= ((ref $self && $self->{VERBOSE}) || $VERBOSE); } # all of the following methods are stripped from CPAN::Version # (as of version 5.5001, bundled in CPAN 2.03), and slightly # modified (ie. made private, as well as CPAN->debug(...) are # replaced with $self->_verbose(9, ...).) # CPAN::Version::vcmp courtesy Jost Krieger sub _vcmp { my($self,$l,$r) = @_; local($^W) = 0; $self->_verbose(9, "l[$l] r[$r]"); return 0 if $l eq $r; # short circuit for quicker success for ($l,$r) { s/_//g; } $self->_verbose(9, "l[$l] r[$r]"); for ($l,$r) { next unless tr/.// > 1 || /^v/; s/^v?/v/; 1 while s/\.0+(\d)/.$1/; # remove leading zeroes per group } $self->_verbose(9, "l[$l] r[$r]"); if ($l=~/^v/ <=> $r=~/^v/) { for ($l,$r) { next if /^v/; $_ = $self->_float2vv($_); } } $self->_verbose(9, "l[$l] r[$r]"); my $lvstring = "v0"; my $rvstring = "v0"; if ($] >= 5.006 && $l =~ /^v/ && $r =~ /^v/) { $lvstring = $self->_vstring($l); $rvstring = $self->_vstring($r); $self->_verbose(9, sprintf "lv[%vd] rv[%vd]", $lvstring, $rvstring); } return ( ($l ne "undef") <=> ($r ne "undef") || $lvstring cmp $rvstring || $l <=> $r || $l cmp $r ); } 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 encounter any issue, that's most probably because of my modification. 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 As of version 0.17, Parse::PMFile stops forking while parsing a version for better performance. Parse::PMFile should return the same result no matter how this option is set, but if you do care, set this to true to fork as PAUSE does. =item USERID, PERMISSIONS As of version 0.21, Parse::PMFile checks permissions of a package if both USERID and PERMISSIONS (which should be an instance of L) are provided. Unauthorized packages are removed. =item UNSAFE Parse::PMFile usually parses a module version in a Safe compartment. However, this approach doesn't work smoothly under older perls (prior to 5.10) plus some combinations of recent versions of Safe.pm (2.24 and above) and version.pm (0.9905 and above) for various reasons. As of version 0.27, Parse::PMFile simply uses C to parse a version under older perls. If you want it to use always C (even under recent perls), set this to true. =back =head2 parse takes a path to a .pm file, and returns a hash reference that holds information for package(s) found in the file. =head1 SEE ALSO L, L Most part of this module is derived from PAUSE and CPAN::Version. L L =head1 AUTHOR Andreas Koenig Eandreas.koenig@anima.deE Kenichi Ishigaki, Eishigaki@cpan.orgE =head1 COPYRIGHT AND LICENSE Copyright 1995 - 2013 by Andreas Koenig Eandk@cpan.orgE for most of the code. Copyright 2013 by Kenichi Ishigaki for some. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. =cut Parse-PMFile-0.43/t/0000755000175000017500000000000013765001010014222 5ustar ishigakiishigakiParse-PMFile-0.43/t/76_qv_without_using_version_and_our.t0000644000175000017500000000125512442256375023641 0ustar ishigakiishigakiuse strict; use warnings; use Test::More; use Parse::PMFile; use File::Temp; my $tmpdir = File::Temp->newdir(CLEANUP => 1); plan skip_all => "tmpdir is not ready" unless -e $tmpdir && -w $tmpdir; my $pmfile = "$tmpdir/Test.pm"; { open my $fh, '>', $pmfile or plan skip_all => "Failed to create a pmfile"; print $fh "package " . "Parse::PMFile::Test;\n"; print $fh '$Parse::PMFile::Test::VERSION = qv("v0.0.1");',"\n"; close $fh; } for (0..1) { no warnings 'once'; local $Parse::PMFile::FORK = $_; my $parser = Parse::PMFile->new; my $info = $parser->parse($pmfile); ok $info->{'Parse::PMFile::Test'}{version} eq '0.000001'; note explain $info; } done_testing; Parse-PMFile-0.43/t/80_version_overload.t0000644000175000017500000000145612440015421020304 0ustar ishigakiishigakiuse strict; use warnings; use Test::More; use FindBin; use Parse::PMFile; for my $fork (0..1) { test_version($fork); no warnings 'once'; local $Parse::PMFile::FORK = $_; my $p = Parse::PMFile->new; my $pkg = $p->parse("$FindBin::Bin/../lib/Parse/PMFile.pm"); is $pkg->{'Parse::PMFile'}{version} => $Parse::PMFile::VERSION, "version of Parse::PMFile matches \$Parse::PMFile::VERSION"; test_version($fork); } done_testing; sub test_version { my $fork = shift; # Does version.pm work correctly after Parse::PMFile is used? my $v1 = version->parse('0.01'); my $v2 = version->parse('0.02'); ok $v1 < $v2, "FORK $fork: 0.02 should be greater than 0.01"; ok $v1 lt $v2, "FORK $fork: 0.02 should be greater than 0.01"; ok (($v1 ? 1 : 0), "FORK $fork: bool"); note "v1: $v1 v2: $v2"; } Parse-PMFile-0.43/t/60_permissions.t0000644000175000017500000000260212440006460017272 0ustar ishigakiishigakiuse strict; use warnings; use Test::More; use Parse::PMFile; use File::Temp; plan skip_all => "requires PAUSE::Permissions to test" unless eval "use PAUSE::Permissions 0.08; 1"; my $tmpdir = File::Temp->newdir(CLEANUP => 1); plan skip_all => "tmpdir is not ready" unless -e $tmpdir && -w $tmpdir; my $pmfile = "$tmpdir/Test.pm"; { open my $fh, '>', $pmfile or plan skip_all => "Failed to create a pmfile"; print $fh "package " . "Parse::PMFile::Test;\n"; print $fh 'our $VERSION = "0.01";',"\n"; close $fh; } my $permsfile = "$tmpdir/06perms.txt"; { open my $fh, '>', $permsfile or plan skip_all => "Failed to create a 06perms.txt"; print $fh "File: 06perms.txt\n"; print $fh "\n"; print $fh "Parse::PMFile::Test,FIRSTCOME,f\n"; print $fh "Parse::PMFile::Test,MAINT,m\n"; print $fh "Parse::PMFile::Test,COMAINT,c\n"; close $fh; } my $permissions = PAUSE::Permissions->new(path => "$tmpdir/06perms.txt"); for (0..1) { no warnings 'once'; local $Parse::PMFile::FORK = $_; for my $user (qw/FIRSTCOME MAINT COMAINT UNKNOWN/) { my $parser = Parse::PMFile->new(undef, {USERID => $user, PERMISSIONS => $permissions}); my $info = $parser->parse($pmfile); if ($user ne 'UNKNOWN') { ok $info->{'Parse::PMFile::Test'}{version} eq '0.01'; } else { ok !defined $info->{'Parse::PMFile::Test'}{version}; } note explain $info; } } done_testing; Parse-PMFile-0.43/t/77_qv_without_our.t0000644000175000017500000000127212442144211020026 0ustar ishigakiishigakiuse strict; use warnings; use Test::More; use Parse::PMFile; use File::Temp; my $tmpdir = File::Temp->newdir(CLEANUP => 1); plan skip_all => "tmpdir is not ready" unless -e $tmpdir && -w $tmpdir; my $pmfile = "$tmpdir/Test.pm"; { open my $fh, '>', $pmfile or plan skip_all => "Failed to create a pmfile"; print $fh "package " . "Parse::PMFile::Test;\n"; print $fh 'use version; $Parse::PMFile::Test::VERSION = qv("v0.0.1");',"\n"; close $fh; } for (0..1) { no warnings 'once'; local $Parse::PMFile::FORK = $_; my $parser = Parse::PMFile->new; my $info = $parser->parse($pmfile); ok $info->{'Parse::PMFile::Test'}{version} eq '0.000001'; note explain $info; } done_testing; Parse-PMFile-0.43/t/70_vpp.t0000644000175000017500000000126712440006460015533 0ustar ishigakiishigakiuse strict; use warnings; use Test::More; use Parse::PMFile; use File::Temp; my $tmpdir = File::Temp->newdir(CLEANUP => 1); plan skip_all => "tmpdir is not ready" unless -e $tmpdir && -w $tmpdir; my $pmfile = "$tmpdir/Test.pm"; { open my $fh, '>', $pmfile or plan skip_all => "Failed to create a pmfile"; print $fh "package " . "Parse::PMFile::Test;\n"; print $fh 'use version; our $VERSION = version->declare("v0.0.1");',"\n"; close $fh; } for (0..1) { no warnings 'once'; local $Parse::PMFile::FORK = $_; my $parser = Parse::PMFile->new; my $info = $parser->parse($pmfile); ok $info->{'Parse::PMFile::Test'}{version} eq '0.000001'; note explain $info; } done_testing; Parse-PMFile-0.43/t/35_scoped_our_version.t0000644000175000017500000000120212452161000020616 0ustar ishigakiishigakiuse strict; use warnings; use Test::More; use Parse::PMFile; use File::Temp; my $tmpdir = File::Temp->newdir(CLEANUP => 1); plan skip_all => "tmpdir is not ready" unless -e $tmpdir && -w $tmpdir; my $pmfile = "$tmpdir/Test.pm"; open my $fh, '>', $pmfile or plan skip_all => "Failed to create a pmfile"; print $fh "package " . "Parse::PMFile::Test;\n"; print $fh '{ our $VERSION = "0.01"; }', "\n"; close $fh; for (0..1) { no warnings 'once'; local $Parse::PMFile::FORK = $_; my $parser = Parse::PMFile->new; my $info = $parser->parse($pmfile); ok $info->{'Parse::PMFile::Test'}{version}; note explain $info; } done_testing; Parse-PMFile-0.43/t/75_vpp_without_our.t0000644000175000017500000000131012442256361020206 0ustar ishigakiishigakiuse strict; use warnings; use Test::More; use Parse::PMFile; use File::Temp; my $tmpdir = File::Temp->newdir(CLEANUP => 1); plan skip_all => "tmpdir is not ready" unless -e $tmpdir && -w $tmpdir; my $pmfile = "$tmpdir/Test.pm"; { open my $fh, '>', $pmfile or plan skip_all => "Failed to create a pmfile"; print $fh "package " . "Parse::PMFile::Test;\n"; print $fh 'use version; $Parse::PMFile::Test::VERSION = version->declare("v0.0.1");',"\n"; close $fh; } for (0..1) { no warnings 'once'; local $Parse::PMFile::FORK = $_; my $parser = Parse::PMFile->new; my $info = $parser->parse($pmfile); ok $info->{'Parse::PMFile::Test'}{version} eq '0.000001'; note explain $info; } done_testing; Parse-PMFile-0.43/t/72_vpp_without_using_version.t0000644000175000017500000000125212442143750022272 0ustar ishigakiishigakiuse strict; use warnings; use Test::More; use Parse::PMFile; use File::Temp; my $tmpdir = File::Temp->newdir(CLEANUP => 1); plan skip_all => "tmpdir is not ready" unless -e $tmpdir && -w $tmpdir; my $pmfile = "$tmpdir/Test.pm"; { open my $fh, '>', $pmfile or plan skip_all => "Failed to create a pmfile"; print $fh "package " . "Parse::PMFile::Test;\n"; print $fh 'our $VERSION = version->declare("v0.0.1");',"\n"; close $fh; } for (0..1) { no warnings 'once'; local $Parse::PMFile::FORK = $_; my $parser = Parse::PMFile->new; my $info = $parser->parse($pmfile); ok $info->{'Parse::PMFile::Test'}{version} eq '0.000001'; note explain $info; } done_testing; Parse-PMFile-0.43/t/40_package_versions.t0000644000175000017500000000207312440006460020242 0ustar ishigakiishigakiuse strict; use warnings; use Test::More; use Parse::PMFile; use File::Temp; my $tmpdir = File::Temp->newdir(CLEANUP => 1); plan skip_all => "tmpdir is not ready" unless -e $tmpdir && -w $tmpdir; test('package '.'Parse::PMFile::Test', <<'TEST'); { $Parse::PMFile::Test::VERSION = "0.01"; } TEST test('package '.'Parse::PMFile::Test', <<'TEST'); { $VERSION = "0.01"; } TEST test('package '.'Parse::PMFile::Test {', <<'TEST'); $Parse::PMFile::Test::VERSION = "0.01"; }; TEST test('package '.'Parse::PMFile::Test {', <<'TEST'); $VERSION = "0.01"; }; TEST test('package '.'Parse::PMFile::Test 0.01 {', <<'TEST'); }; TEST sub test { my @lines = @_; my $pmfile = "$tmpdir/Test.pm"; open my $fh, '>', $pmfile or plan skip_all => "Failed to create a pmfile"; print $fh join "\n", @lines, ""; close $fh; for (0..1) { no warnings 'once'; local $Parse::PMFile::FORK = $_; my $parser = Parse::PMFile->new; my $info = $parser->parse($pmfile); is $info->{'Parse::PMFile::Test'}{version} => '0.01'; # note explain $info; } } done_testing; Parse-PMFile-0.43/t/34_math_version.t0000644000175000017500000000166112644220525017430 0ustar ishigakiishigakiuse strict; use warnings; use Test::More; use Parse::PMFile; use File::Temp; use Opcode; use Safe; diag "atan2: ".atan2(1,1) * 4; diag "Safe: $Safe::VERSION"; diag "Opcode: $Opcode::VERSION"; my $tmpdir = File::Temp->newdir(CLEANUP => 1); plan skip_all => "tmpdir is not ready" unless -e $tmpdir && -w $tmpdir; my $pmfile = "$tmpdir/Test.pm"; open my $fh, '>', $pmfile or plan skip_all => "Failed to create a pmfile"; print $fh "package " . "Parse::PMFile::Test;\n"; print $fh 'my $version = atan2(1,1) * 4; $Parse::PMFile::Test::VERSION = substr("$version", 0, 16);', "\n"; # from Acme-Pi-3, modified to limit the length not to fail under perls with -Duselongdouble close $fh; for (0..1) { no warnings 'once'; local $Parse::PMFile::FORK = $_; my $parser = Parse::PMFile->new; my $info = $parser->parse($pmfile); is substr($info->{'Parse::PMFile::Test'}{version} || '', 0, 4) => "3.14"; #note explain $info; } done_testing; Parse-PMFile-0.43/t/99_pod.t0000644000175000017500000000032712440006460015517 0ustar ishigakiishigakiuse strict; use warnings; use Test::More; eval "use Test::Pod 1.18"; plan skip_all => 'Test::Pod 1.18 required' if $@; plan skip_all => 'set TEST_POD to enable this test' unless $ENV{TEST_POD}; all_pod_files_ok(); Parse-PMFile-0.43/t/36_long_version.t0000644000175000017500000000134012662250360017432 0ustar ishigakiishigakiuse strict; use warnings; use Test::More; use Parse::PMFile; use File::Temp; my $tmpdir = File::Temp->newdir(CLEANUP => 1); plan skip_all => "tmpdir is not ready" unless -e $tmpdir && -w $tmpdir; my $pmfile = "$tmpdir/Test.pm"; open my $fh, '>', $pmfile or plan skip_all => "Failed to create a pmfile"; print $fh "package " . "Parse::PMFile::Test;\n"; print $fh '{ our $VERSION = "0.000000000000001"; }', "\n"; close $fh; for (0..1) { no warnings 'once'; local $Parse::PMFile::FORK = $_; my $parser = Parse::PMFile->new; my ($info, $err) = $parser->parse($pmfile); ok !$info->{'Parse::PMFile::Test'}{version}; note explain $info; ok $err->{'Parse::PMFile::Test'}{long_version}; note explain $err; } done_testing; Parse-PMFile-0.43/t/74_vpp_without_using_version_and_our.t0000644000175000017500000000127312442461771024014 0ustar ishigakiishigakiuse strict; use warnings; use Test::More; use Parse::PMFile; use File::Temp; my $tmpdir = File::Temp->newdir(CLEANUP => 1); plan skip_all => "tmpdir is not ready" unless -e $tmpdir && -w $tmpdir; my $pmfile = "$tmpdir/Test.pm"; { open my $fh, '>', $pmfile or plan skip_all => "Failed to create a pmfile"; print $fh "package " . "Parse::PMFile::Test;\n"; print $fh '$Parse::PMFile::Test::VERSION = version->declare("v0.0.1");',"\n"; close $fh; } for (0..1) { no warnings 'once'; local $Parse::PMFile::FORK = $_; my $parser = Parse::PMFile->new; my $info = $parser->parse($pmfile); ok $info->{'Parse::PMFile::Test'}{version} eq '0.000001'; note explain $info; } done_testing; Parse-PMFile-0.43/t/90_lossy_warning.t0000644000175000017500000000163012662253350017630 0ustar ishigakiishigakiuse strict; use warnings; use Test::More; use Parse::PMFile; use File::Temp; my $tmpdir = File::Temp->newdir(CLEANUP => 1); plan skip_all => "tmpdir is not ready" unless -e $tmpdir && -w $tmpdir; my $pmfile = "$tmpdir/Test.pm"; { open my $fh, '>', $pmfile or plan skip_all => "Failed to create a pmfile"; print $fh "package " . "Parse::PMFile::Test;\n"; print $fh 'our $VERSION = qv("1.51_01");',"\n"; close $fh; } for (0..1) { no warnings 'once'; local $Parse::PMFile::FORK = $_; my $parser = Parse::PMFile->new(undef, {ALLOW_DEV_VERSION => 1}); { my $expected = (version->VERSION > 0.9912) ? "1.5101000" : "1.051_001"; my @warnings; local $SIG{__WARN__} = sub {push @warnings, @_}; my $info = $parser->parse($pmfile); is $info->{'Parse::PMFile::Test'}{version} => $expected; note explain $info; ok !@warnings; note join "\n", @warnings; } } done_testing; Parse-PMFile-0.43/t/73_qv_without_using_version.t0000644000175000017500000000123412442143755022121 0ustar ishigakiishigakiuse strict; use warnings; use Test::More; use Parse::PMFile; use File::Temp; my $tmpdir = File::Temp->newdir(CLEANUP => 1); plan skip_all => "tmpdir is not ready" unless -e $tmpdir && -w $tmpdir; my $pmfile = "$tmpdir/Test.pm"; { open my $fh, '>', $pmfile or plan skip_all => "Failed to create a pmfile"; print $fh "package " . "Parse::PMFile::Test;\n"; print $fh 'our $VERSION = qv("v0.0.1");',"\n"; close $fh; } for (0..1) { no warnings 'once'; local $Parse::PMFile::FORK = $_; my $parser = Parse::PMFile->new; my $info = $parser->parse($pmfile); ok $info->{'Parse::PMFile::Test'}{version} eq '0.000001'; note explain $info; } done_testing; Parse-PMFile-0.43/t/10_self_check.t0000644000175000017500000000057312440006460017005 0ustar ishigakiishigakiuse strict; use warnings; use Test::More tests => 2; use FindBin; use Parse::PMFile; for (0..1) { no warnings 'once'; local $Parse::PMFile::FORK = $_; my $p = Parse::PMFile->new; my $pkg = $p->parse("$FindBin::Bin/../lib/Parse/PMFile.pm"); is $pkg->{'Parse::PMFile'}{version} => $Parse::PMFile::VERSION, "version of Parse::PMFile matches \$Parse::PMFile::VERSION"; } Parse-PMFile-0.43/t/32_allow_dev_version.t0000644000175000017500000000330612440006460020441 0ustar ishigakiishigakiuse strict; use warnings; use Test::More; use Parse::PMFile; use File::Temp; my $tmpdir = File::Temp->newdir(CLEANUP => 1); plan skip_all => "tmpdir is not ready" unless -e $tmpdir && -w $tmpdir; my $pmfile = "$tmpdir/Test.pm"; open my $fh, '>', $pmfile or plan skip_all => "Failed to create a pmfile"; print $fh "package " . "Parse::PMFile::Test;\n"; print $fh 'our $VERSION = "0.01_01";',"\n"; # this should be ignored close $fh; for (0..1) { no warnings 'once'; local $Parse::PMFile::FORK = $_; local $Parse::PMFile::ALLOW_DEV_VERSION = 0; my $parser = Parse::PMFile->new; my $info = $parser->parse($pmfile); ok !$info->{'Parse::PMFile::Test'}{version}; note explain $info; } for (0..1) { no warnings 'once'; local $Parse::PMFile::FORK = $_; local $Parse::PMFile::ALLOW_DEV_VERSION = 0; my $parser = Parse::PMFile->new({ provides => { 'Parse::PMFile::Test' => { version => '0.01_01', }, }, }); my $info = $parser->parse($pmfile); ok !$info->{'Parse::PMFile::Test'}{version}; note explain $info; } for (0..1) { no warnings 'once'; local $Parse::PMFile::FORK = $_; local $Parse::PMFile::ALLOW_DEV_VERSION = 1; my $parser = Parse::PMFile->new; my $info = $parser->parse($pmfile); ok $info->{'Parse::PMFile::Test'}{version} eq '0.01_01'; note explain $info; } for (0..1) { no warnings 'once'; local $Parse::PMFile::FORK = $_; local $Parse::PMFile::ALLOW_DEV_VERSION = 1; my $parser = Parse::PMFile->new({ provides => { 'Parse::PMFile::Test' => { version => '0.01_01', }, }, }); my $info = $parser->parse($pmfile); ok $info->{'Parse::PMFile::Test'}{version} eq '0.01_01'; note explain $info; } done_testing; Parse-PMFile-0.43/t/00_load.t0000644000175000017500000000011712440006460015627 0ustar ishigakiishigakiuse strict; use warnings; use Test::More tests => 1; use_ok('Parse::PMFile'); Parse-PMFile-0.43/t/31_ignore_version_after_end.t0000644000175000017500000000127312440006460021757 0ustar ishigakiishigakiuse strict; use warnings; use Test::More; use Parse::PMFile; use File::Temp; my $tmpdir = File::Temp->newdir(CLEANUP => 1); plan skip_all => "tmpdir is not ready" unless -e $tmpdir && -w $tmpdir; my $pmfile = "$tmpdir/Test.pm"; open my $fh, '>', $pmfile or plan skip_all => "Failed to create a pmfile"; print $fh "package " . "Parse::PMFile::Test;\n"; print $fh "\n__END__\n"; print $fh 'our $VERSION = "0.01";',"\n"; # this should be ignored close $fh; for (0..1) { no warnings 'once'; local $Parse::PMFile::FORK = $_; my $parser = Parse::PMFile->new; my $info = $parser->parse($pmfile); ok $info->{'Parse::PMFile::Test'}{version} eq 'undef'; note explain $info; } done_testing; Parse-PMFile-0.43/t/30_multiple_equals.t0000644000175000017500000000127212440006460020123 0ustar ishigakiishigakiuse strict; use warnings; use Test::More; use Parse::PMFile; use File::Temp; my $tmpdir = File::Temp->newdir(CLEANUP => 1); plan skip_all => "tmpdir is not ready" unless -e $tmpdir && -w $tmpdir; my $pmfile = "$tmpdir/Test.pm"; open my $fh, '>', $pmfile or plan skip_all => "Failed to create a pmfile"; print $fh "package " . "Parse::PMFile::Test;\n"; print $fh do {local $/; }; close $fh; for (0..1) { no warnings 'once'; local $Parse::PMFile::FORK = $_; my $parser = Parse::PMFile->new; my $info = $parser->parse($pmfile); is $info->{'Parse::PMFile::Test'}{version} => '1.12'; } done_testing; __DATA__ our $VERSION = sprintf("%d.%02d", q$Revision: 1.12 $=~/(\d+)\.(\d+)/); Parse-PMFile-0.43/t/81_version_overload_with_explicit_vpp.t0000644000175000017500000000221412440021317024120 0ustar ishigakiishigakiuse strict; use warnings; use Test::More; use FindBin; use Parse::PMFile; eval "use version::vpp; 1" or plan skip_all => "requires version::vpp"; for my $fork (0..1) { test_version($fork); no warnings 'once'; local $Parse::PMFile::FORK = $_; my $p = Parse::PMFile->new; my $pkg = $p->parse("$FindBin::Bin/../lib/Parse/PMFile.pm"); is $pkg->{'Parse::PMFile'}{version} => $Parse::PMFile::VERSION, "version of Parse::PMFile matches \$Parse::PMFile::VERSION"; test_version($fork); } done_testing; sub test_version { my $fork = shift; # Does version.pm work correctly after Parse::PMFile is used? my $v1 = version->parse('0.01'); my $v2 = version->parse('0.02'); ok $v1 < $v2, "FORK $fork: 0.02 should be greater than 0.01"; ok $v1 lt $v2, "FORK $fork: 0.02 should be greater than 0.01"; ok (($v1 ? 1 : 0), "FORK $fork: bool"); note "v1: $v1 v2: $v2"; my $v3 = version::vpp->parse('0.03'); my $v4 = version::vpp->parse('0.04'); ok $v3 < $v4, "FORK $fork: 0.04 should be greater than 0.03"; ok $v3 lt $v4, "FORK $fork: 0.04 should be greater than 0.03"; ok (($v3 ? 1 : 0), "FORK $fork: bool"); note "v3: $v3 v4: $v4"; } Parse-PMFile-0.43/t/99_podcoverage.t0000644000175000017500000000035712440006460017236 0ustar ishigakiishigakiuse strict; use warnings; use Test::More; eval "use Test::Pod::Coverage 1.04"; plan skip_all => 'Test::Pod::Coverage 1.04 required' if $@; plan skip_all => 'set TEST_POD to enable this test' unless $ENV{TEST_POD}; all_pod_coverage_ok(); Parse-PMFile-0.43/t/71_qv.t0000644000175000017500000000125112440006460015346 0ustar ishigakiishigakiuse strict; use warnings; use Test::More; use Parse::PMFile; use File::Temp; my $tmpdir = File::Temp->newdir(CLEANUP => 1); plan skip_all => "tmpdir is not ready" unless -e $tmpdir && -w $tmpdir; my $pmfile = "$tmpdir/Test.pm"; { open my $fh, '>', $pmfile or plan skip_all => "Failed to create a pmfile"; print $fh "package " . "Parse::PMFile::Test;\n"; print $fh 'use version; our $VERSION = qv("v0.0.1");',"\n"; close $fh; } for (0..1) { no warnings 'once'; local $Parse::PMFile::FORK = $_; my $parser = Parse::PMFile->new; my $info = $parser->parse($pmfile); ok $info->{'Parse::PMFile::Test'}{version} eq '0.000001'; note explain $info; } done_testing; Parse-PMFile-0.43/t/50_no_index.t0000644000175000017500000000132012440006460016515 0ustar ishigakiishigakiuse strict; use warnings; use Test::More; use Parse::PMFile; use File::Temp; my $tmpdir = File::Temp->newdir(CLEANUP => 1); plan skip_all => "tmpdir is not ready" unless -e $tmpdir && -w $tmpdir; my $pmfile = "$tmpdir/Test.pm"; open my $fh, '>', $pmfile or plan skip_all => "Failed to create a pmfile"; print $fh "package " . "Parse::PMFile::Test;\n"; print $fh 'our $VERSION = "0.01";', "\n"; close $fh; for (0..1) { no warnings 'once'; local $Parse::PMFile::FORK = $_; my $parser = Parse::PMFile->new({ no_index => { package => [qw/ Parse::PMFile::Test /] } }); my $info = $parser->parse($pmfile); ok !$info->{'Parse::PMFile::Test'}; note explain $info; } done_testing; Parse-PMFile-0.43/t/33_ignore_variable_named_package.t0000644000175000017500000000127612440006460022674 0ustar ishigakiishigakiuse strict; use warnings; use Test::More; use Parse::PMFile; use File::Temp; my $tmpdir = File::Temp->newdir(CLEANUP => 1); plan skip_all => "tmpdir is not ready" unless -e $tmpdir && -w $tmpdir; my $pmfile = "$tmpdir/Test.pm"; open my $fh, '>', $pmfile or plan skip_all => "Failed to create a pmfile"; print $fh 'my $package = qq{Parse::PMFile::Test};', "\n"; print $fh '$package or', "\n"; print $fh 'die;', "\n"; print $fh 'our $VERSION = "0.01";',"\n"; # this should be ignored close $fh; for (0..1) { no warnings 'once'; local $Parse::PMFile::FORK = $_; my $parser = Parse::PMFile->new; my $info = $parser->parse($pmfile); ok !$info->{'or'}; note explain $info; } done_testing; Parse-PMFile-0.43/META.json0000644000175000017500000000244413765001010015404 0ustar ishigakiishigaki{ "abstract" : "parses .pm file as PAUSE does", "author" : [ "Kenichi Ishigaki " ], "dynamic_config" : 0, "generated_by" : "ExtUtils::MakeMaker version 7.24, CPAN::Meta::Converter version 2.150010", "license" : [ "perl_5" ], "meta-spec" : { "url" : "http://search.cpan.org/perldoc?CPAN::Meta::Spec", "version" : 2 }, "name" : "Parse-PMFile", "no_index" : { "directory" : [ "t", "inc" ] }, "prereqs" : { "build" : { "requires" : { "ExtUtils::MakeMaker" : "0" } }, "configure" : { "requires" : { "ExtUtils::MakeMaker::CPANfile" : "0.08" } }, "runtime" : { "requires" : { "Dumpvalue" : "0", "File::Spec" : "0", "JSON::PP" : "2.00", "Safe" : "0", "version" : "0.83" } }, "test" : { "requires" : { "File::Temp" : "0.19", "Test::More" : "0.88" } } }, "release_status" : "stable", "resources" : { "repository" : { "url" : "https://github.com/charsbar/Parse-PMFile" } }, "version" : "0.43", "x_serialization_backend" : "JSON::PP version 4.00" } Parse-PMFile-0.43/Changes0000644000175000017500000001037013765000753015270 0ustar ishigakiishigakiRevision history for Parse-PMFile 0.43 2020/12/12 - Avoid instantiating `Safe` compartment if operating in "unsafe" mode. (GH#12; bleargh45++) 0.42 2019/11/09 - no code changes - explicitly declared ExtUtils::MakeMaker::CPANfile as a configure requirement (Nikolo++) 0.41 2016/11/03 - not to count package declaration in a string - treat a package that contains multiple singlequotes correctly 0.40 2016/02/21 - silenced "alpha->numify() is lossy" warning 0.39 2016/01/10 - no code changes - fixed 34_math_version.t not to fail under perls with -Duselongdouble (RT#111034, srezic++) 0.38 2016/01/09 - no code changes - added diagnostic messages to find the reason of sporadic fail reports from Testers with recent perls 0.37 2016/01/07 - ported version_ok() implemented in PAUSE to disallow a VERSION that is too long to store correctly in the PAUSE database 0.36 2015/04/16 - removed an unnecessary $DB::single line (oalders++) 0.35 2015/01/17 - fixed to tolerate version line errors as undef (miyagawa++) 0.34 2015/01/04 - fixed a case where our $VERSION is in a block. (ether++, mst++) 0.33 2014/12/13 - reverted the change in 0.32 to store overloaded stuff in the object which seems to have caused segfaults under some environments 0.32 2014/12/12 - improved version->declare handling (by numifying earlier for Safe not to do with a version object) - stored overloaded stuff in the object 0.31 2014/12/09 - fixed cases where version->declare / qv() used in the VERSION line without using version explicitly 0.30 2014/12/05 - restore overloaded stuff from version::vpp as well (if necessary) (haarg++) 0.29 2014/10/10 - silenced a redefinition warning 0.28 2014/10/08 - import qv into main package if UNSAFE - reverted restoring overloaded stuff from version.pm (miyagawa++ for both) 0.27 2014/10/08 - added UNSAFE option for older perls plus recent versions of Safe/version - restore overloaded stuff from version.pm 0.26 2014/09/17 - version::vpp should also be numified 0.25 2014/09/17 - hid charstar from PAUSE 0.24 2014/09/17 - improved fatpacked version::vpp support 0.23 2014/09/16 - let Safe compartment share charstar:: stuff so that older perls forced to use version::vpp can correctly parse $VERSION declared by version->declare. (miyagawa++) 0.22 2014/09/02 - tweak for backward compatibility 0.21 2014/09/02 - implemented permission check - constructor options 0.20 2014/08/14 - not to consider \$VERSION in a regexp as a $VERSION 0.19 2014/04/30 - restore in-core version overloads correctly - bumped up the version requirement slightly (moznion++) 0.18 2014/04/28 - make sure to erase stuff in Safe.pm and restore overloaded version.pm stuff so that version.pm works correctly after parsing versions via Parse::PMFile - cpanfile 0.17 2014/04/15 - not to fork by default 0.16 2014/04/11 - reflected the changes done in PAUSE at QAH 2014 0.15 2014/03/17 - no_index for package/namespace hasn't been applied correctly 0.14 2014/03/15 - updated MANIFEST and included a few tests for 0.13 0.13 2014/03/15 - tweaked to allow math functions in VERSION specification (Acme::Pi uses atan2 to define its package version) - fixed parsing of "package NAME BLOCK", which was not suppported (KENTNL++) 0.12 2014/02/19 - fixed *VERSION = *... handling 0.11 2013/11/17 - fixed *VERSION = \... handling - fixed VERSION detection to ignore version comparison - keep error infile as well - silenced warnings 0.10 2013/10/12 - keep normalization errors as well 0.09 2013/10/10 - silenced warnings 0.08 2013/10/10 - added a feature to return info about invalid versions 0.07 2013/10/01 - made it ignore "$package or" (previously this was wrongly detected as "or" package) 0.06 2013/09/26 - included all of the CPAN::Version methods to drop CPAN(::Version) dependency 0.05 2013/07/25 - switched to JSON::PP (per request of miyagawa) 0.04 2013/06/15 - added minimum protection against Acme::BadExample 0.03 2013/06/15 - added $ALLOW_DEV_VERSION for analysis - made it ignore $VERSIONs after __(END|DATA)__ 0.02 2013/05/13 - tweaked package version detection not to take too much time 0.01 2013/05/05 - initial release Parse-PMFile-0.43/Makefile.PL0000644000175000017500000000070412440006460015735 0ustar ishigakiishigakiuse strict; use warnings; use ExtUtils::MakeMaker::CPANfile; my %params = ( NAME => 'Parse::PMFile', AUTHOR => 'Kenichi Ishigaki ', VERSION_FROM => 'lib/Parse/PMFile.pm', ABSTRACT_FROM => 'lib/Parse/PMFile.pm', LICENSE => 'perl', META_MERGE => { resources => { repository => 'https://github.com/charsbar/Parse-PMFile', }, }, ); WriteMakefile(%params); Parse-PMFile-0.43/META.yml0000644000175000017500000000135413765001010015233 0ustar ishigakiishigaki--- abstract: 'parses .pm file as PAUSE does' author: - 'Kenichi Ishigaki ' build_requires: ExtUtils::MakeMaker: '0' File::Temp: '0.19' Test::More: '0.88' configure_requires: ExtUtils::MakeMaker::CPANfile: '0.08' dynamic_config: 0 generated_by: 'ExtUtils::MakeMaker version 7.24, CPAN::Meta::Converter version 2.150010' license: perl meta-spec: url: http://module-build.sourceforge.net/META-spec-v1.4.html version: '1.4' name: Parse-PMFile no_index: directory: - t - inc requires: Dumpvalue: '0' File::Spec: '0' JSON::PP: '2.00' Safe: '0' version: '0.83' resources: repository: https://github.com/charsbar/Parse-PMFile version: '0.43' x_serialization_backend: 'CPAN::Meta::YAML version 0.012' Parse-PMFile-0.43/cpanfile0000644000175000017500000000064113561426670015505 0ustar ishigakiishigakirequires 'Dumpvalue' => 0; requires 'File::Spec' => 0; requires 'JSON::PP' => '2.00'; requires 'Safe' => 0; requires 'version' => '0.83'; configure_requires 'ExtUtils::MakeMaker::CPANfile' => '0.07'; on test => sub { requires 'File::Temp' => '0.19'; # newdir requires 'Test::More' => '0.88'; }; on develop => sub { requires 'PAUSE::Permissions' => '0.08' if $] > 5.010000; requires 'WorePAN' => '0.13'; }; Parse-PMFile-0.43/MANIFEST0000644000175000017500000000152713765001010015115 0ustar ishigakiishigakiChanges cpanfile lib/Parse/PMFile.pm Makefile.PL MANIFEST This list of files README t/00_load.t t/10_self_check.t t/30_multiple_equals.t t/31_ignore_version_after_end.t t/32_allow_dev_version.t t/33_ignore_variable_named_package.t t/34_math_version.t t/35_scoped_our_version.t t/36_long_version.t t/40_package_versions.t t/50_no_index.t t/60_permissions.t t/70_vpp.t t/71_qv.t t/72_vpp_without_using_version.t t/73_qv_without_using_version.t t/74_vpp_without_using_version_and_our.t t/75_vpp_without_our.t t/76_qv_without_using_version_and_our.t t/77_qv_without_our.t t/80_version_overload.t t/81_version_overload_with_explicit_vpp.t t/90_lossy_warning.t t/99_pod.t t/99_podcoverage.t META.yml Module YAML meta-data (added by MakeMaker) META.json Module JSON meta-data (added by MakeMaker)