Skip to content

Commit

Permalink
Packages with leading underscores not indexed
Browse files Browse the repository at this point in the history
  • Loading branch information
andreeap committed Jan 28, 2015
1 parent 3f783f9 commit cdbdf04
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
6 changes: 6 additions & 0 deletions lib/MetaCPAN/Document/File.pm
Original file line number Diff line number Diff line change
Expand Up @@ -704,6 +704,12 @@ does not include any modules, the L</indexed> property is true.
sub set_indexed {
my ( $self, $meta ) = @_;

foreach my $mod ( @{ $self->module } ) {
if ( $mod->name =~ /^[_*]/ ) {
$mod->indexed(0);
}
}

foreach my $mod ( @{ $self->module } ) {
$mod->indexed(
$meta->should_index_package( $mod->name )
Expand Down
8 changes: 8 additions & 0 deletions t/document/file.t
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,14 @@ END
};
};

subtest 'Packages starting with underscore are not indexed' => sub {
my $file = MetaCPAN::Document::File->new( %stub,
module => { name => '_Package::Foo' } );

$file->set_indexed( CPAN::Meta->new( { name => 'null', version => 0 } ) );
is( $file->module->[0]->indexed, 0, 'Package is not indexed' );
};

subtest 'module below .../t/' => sub {
my $file = MetaCPAN::Document::File->new(
%stub,
Expand Down

0 comments on commit cdbdf04

Please sign in to comment.