}
}
+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
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
);
my %pkg_names = reverse @pkg_names;
-plan tests => 54 + (2 * keys( %modules )) + (2 * keys( %pkg_names ));
+plan tests => 63 + (2 * keys( %modules )) + (2 * keys( %pkg_names ));
require_ok('Module::Metadata');
is( $pm_info->version, undef, 'version for default package' );
is( $pm_info->version('simple'), '0.01', 'version for lower-case package' );
is( $pm_info->version('Simple'), undef, 'version for capitalized package' );
+ ok( $pm_info->is_indexable(), 'an indexable package is found' );
+ ok( $pm_info->is_indexable('simple'), 'the simple package is indexable' );
+ ok( !$pm_info->is_indexable('Simple'), 'the Simple package would not be indexed' );
$dist->change_file( 'lib/Simple.pm', <<'---' );
package simple;
is( $pm_info->version('simple'), '0.01', 'version for lower-case package' );
is( $pm_info->version('Simple'), '0.02', 'version for capitalized package' );
is( $pm_info->version('SiMpLe'), '0.03', 'version for mixed-case package' );
+ ok( $pm_info->is_indexable('simple'), 'the simple package is indexable' );
+ ok( $pm_info->is_indexable('Simple'), 'the Simple package is indexable' );
+
+ $dist->change_file( 'lib/Simple.pm', <<'---' );
+package ## hide from PAUSE
+ simple;
+$VERSION = '0.01';
+---
+
+ $dist->regen;
+
+ $pm_info = Module::Metadata->new_from_file('lib/Simple.pm');
+ is( $pm_info->name, undef, 'no package names found' );
+ ok( !$pm_info->is_indexable('simple'), 'the simple package would not be indexed' );
+ ok( !$pm_info->is_indexable('Simple'), 'the Simple package would not be indexed' );
+ ok( !$pm_info->is_indexable(), 'no indexable package is found' );
}