Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Packages with leading underscores should not be indexed
  • Loading branch information
andreeap committed Jan 31, 2015
1 parent e4981c7 commit 141117f
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
8 changes: 8 additions & 0 deletions lib/MetaCPAN/Document/File.pm
Expand Up @@ -687,6 +687,10 @@ Expects a C<$meta> parameter which is an instance of L<CPAN::Meta>.
For each package (L</module>) in the file and based on L<CPAN::Meta/should_index_package>
it is decided, whether the module should have a true L</indexed> attribute.
If there are any packages with leading underscores, the module gets a false
L</indexed> attribute, because PAUSE doesn't allow this kind of name for packages
(https://github.com/andk/pause/blob/master/lib/PAUSE/pmfile.pm#L249).
If L<CPAN::Meta/should_index_package> returns true but the package declaration
uses the I<hide from PAUSE> hack, the L</indexed> property is set to false.
Expand All @@ -705,6 +709,10 @@ sub set_indexed {
my ( $self, $meta ) = @_;

foreach my $mod ( @{ $self->module } ) {
if ( $mod->name !~ /^[A-Za-z]/ ) {
$mod->indexed(0);
next;
}
$mod->indexed(
$meta->should_index_package( $mod->name )
? $mod->hide_from_pause( ${ $self->content }, $self->name )
Expand Down
5 changes: 5 additions & 0 deletions t/document/file.t
Expand Up @@ -207,6 +207,11 @@ END
};
};

subtest 'Packages starting with underscore are not indexed' => sub {
my $file = new_file_doc( module => { name => '_Package::Foo' } );
is( $file->module->[0]->indexed, 0, 'Package is not indexed' );
};

subtest 'pod name/package mismatch' => sub {
my $content = <<'END';
package
Expand Down

0 comments on commit 141117f

Please sign in to comment.