is_indexable( [ $package ] )
[p5sagit/Module-Metadata.git] / lib / Module / Metadata.pm
index a9a81ef..d11c8c0 100644 (file)
@@ -10,8 +10,9 @@ package Module::Metadata;
 # parrot future to look at other types of modules).
 
 use strict;
-use vars qw($VERSION);
-$VERSION = '1.000016';
+use warnings;
+
+our $VERSION = '1.000019';
 $VERSION = eval $VERSION;
 
 use Carp qw/croak/;
@@ -86,7 +87,7 @@ my $VERS_REGEXP = qr{ # match a VERSION definition
     $VARNAME_REGEXP           # without parens
   )
   \s*
-  =[^=~]  # = but not ==, nor =~
+  =[^=~>]  # = but not ==, nor =~, nor =>
 }x;
 
 sub new_from_file {
@@ -649,10 +650,11 @@ sub _evaluate_version_line {
   # compiletime/runtime issues with local()
   my $vsub;
   $pn++; # everybody gets their own package
-  my $eval = qq{BEGIN { q#  Hide from _packages_inside()
+  my $eval = qq{BEGIN { my \$dummy = q#  Hide from _packages_inside()
     #; package Module::Metadata::_version::p$pn;
     use version;
     no strict;
+    no warnings;
 
       \$vsub = sub {
         local $sigil$var;
@@ -662,6 +664,8 @@ sub _evaluate_version_line {
       };
   }};
 
+  $eval = $1 if $eval =~ m{^(.+)}s;
+
   local $^W;
   # Try to get the $VERSION
   eval $eval;
@@ -779,6 +783,18 @@ sub pod {
     }
 }
 
+sub is_indexable {
+  my ($self, $package) = @_;
+
+  my @indexable_packages = grep { $_ ne 'main' } $self->packages_inside;
+
+  # check for specific package, if provided
+  return !! grep { $_ eq $package } @indexable_packages if $package;
+
+  # otherwise, check for any indexable packages at all
+  return !! @indexable_packages;
+}
+
 1;
 
 =head1 NAME
@@ -952,7 +968,7 @@ Log::Contextual has already been loaded, otherwise simply calls warn.
 =item C<< name() >>
 
 Returns the name of the package represented by this module. If there
-are more than one packages, it makes a best guess based on the
+is more than one package, it makes a best guess based on the
 filename. If it's a script (i.e. not a *.pm) the package name is
 'main'.
 
@@ -989,6 +1005,13 @@ Returns true if there is any POD in the file.
 
 Returns the POD data in the given section.
 
+=item C<< is_indexable($package) >> or C<< is_indexable() >>
+
+Returns a boolean indicating whether the package (if provided) or any package
+(otherwise) is eligible for indexing by PAUSE, the Perl Authors Upload Server.
+Note This only checks for valid C<package> declarations, and does not take any
+ownership information into account.
+
 =back
 
 =head1 AUTHOR