From 9fc65f9b526315c515b9453b1370dc17b75603b9 Mon Sep 17 00:00:00 2001 From: Andreea Pirvulescu Date: Fri, 30 Jan 2015 18:23:54 +0200 Subject: [PATCH] Packages with leading underscores should not be indexed --- lib/MetaCPAN/Document/File.pm | 7 +++++++ t/document/file.t | 5 +++++ 2 files changed, 12 insertions(+) diff --git a/lib/MetaCPAN/Document/File.pm b/lib/MetaCPAN/Document/File.pm index ccf94edf9..80c1aa51f 100644 --- a/lib/MetaCPAN/Document/File.pm +++ b/lib/MetaCPAN/Document/File.pm @@ -687,6 +687,10 @@ Expects a C<$meta> parameter which is an instance of L. For each package (L) in the file and based on L it is decided, whether the module should have a true L attribute. +If there are any packages with leading underscores, the module gets a false +L 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 returns true but the package declaration uses the I hack, the L property is set to false. @@ -705,6 +709,9 @@ sub set_indexed { my ( $self, $meta ) = @_; foreach my $mod ( @{ $self->module } ) { + if ( $mod->name !~ /^[A-Za-z]/ ) { + $mod->indexed(0); + } $mod->indexed( $meta->should_index_package( $mod->name ) ? $mod->hide_from_pause( ${ $self->content }, $self->name ) diff --git a/t/document/file.t b/t/document/file.t index 032832049..26a301158 100644 --- a/t/document/file.t +++ b/t/document/file.t @@ -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