Skip to content

Commit

Permalink
Merge c8ac5ba into 141117f
Browse files Browse the repository at this point in the history
  • Loading branch information
andreeap committed Feb 18, 2015
2 parents 141117f + c8ac5ba commit 8e15dcb
Show file tree
Hide file tree
Showing 4 changed files with 81 additions and 0 deletions.
1 change: 1 addition & 0 deletions cpanfile
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ requires 'JSON', '2.90';
requires 'LWP::Protocol::https';
requires 'LWP::UserAgent';
requires 'LWP::UserAgent::Paranoid';
requires 'List::AllUtils';
requires 'List::MoreUtils';
requires 'List::Util';
requires 'Log::Contextual';
Expand Down
22 changes: 22 additions & 0 deletions cpanfile.snapshot
Original file line number Diff line number Diff line change
Expand Up @@ -4005,6 +4005,18 @@ DISTRIBUTIONS
requirements:
Test::More 0
version 0
List-AllUtils-0.09
pathname: D/DR/DROLSKY/List-AllUtils-0.09.tar.gz
provides:
List::AllUtils 0.09
requirements:
Exporter 0
ExtUtils::MakeMaker 0
List::MoreUtils 0.28
List::Util 1.31
base 0
strict 0
warnings 0
List-MoreUtils-0.33
pathname: A/AD/ADAMK/List-MoreUtils-0.33.tar.gz
provides:
Expand Down Expand Up @@ -6719,6 +6731,16 @@ DISTRIBUTIONS
Exporter 5.57
ExtUtils::MakeMaker 0
Scalar::Util 0
Scalar-List-Utils-1.41
pathname: P/PE/PEVANS/Scalar-List-Utils-1.41.tar.gz
provides:
List::Util 1.41
List::Util::XS 1.41
Scalar::Util 1.41
Sub::Util 1.41
requirements:
ExtUtils::MakeMaker 0
Test::More 0
Scope-Guard-0.20
pathname: C/CH/CHOCOLATE/Scope-Guard-0.20.tar.gz
provides:
Expand Down
52 changes: 52 additions & 0 deletions lib/MetaCPAN/Document/File.pm
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ use Moose;
use ElasticSearchX::Model::Document;

use Encode;
use List::AllUtils qw( any );
use List::MoreUtils qw(any uniq);
use MetaCPAN::Document::Module;
use MetaCPAN::Pod::XHTML;
Expand Down Expand Up @@ -681,6 +682,52 @@ sub add_module {
$self->module( [ @{ $self->module }, @modules ] );
}

=head2 is_in_other_files
Returns true if the file is one from the list below.
=cut

sub is_in_other_files {
my $self = shift;
my @other = qw(
AUTHORS
Build.PL
Changelog
ChangeLog
CHANGELOG
Changes
CHANGES
CONTRIBUTING
CONTRIBUTING.md
CONTRIBUTING.pod
Copying
COPYRIGHT
cpanfile
CREDITS
dist.ini
FAQ
INSTALL
INSTALL.md
INSTALL.pod
LICENSE
Makefile.PL
MANIFEST
META.json
META.yml
NEWS
README
README.md
README.pod
THANKS
Todo
ToDo
TODO
);

return any { $self->name eq $_ } @other;
}

=head2 set_indexed
Expects a C<$meta> parameter which is an instance of L<CPAN::Meta>.
Expand Down Expand Up @@ -708,6 +755,11 @@ does not include any modules, the L</indexed> property is true.
sub set_indexed {
my ( $self, $meta ) = @_;

#files listed under 'other files' are not shown in a search
if ( $self->is_in_other_files() ) {
$self->indexed(0);
}

foreach my $mod ( @{ $self->module } ) {
if ( $mod->name !~ /^[A-Za-z]/ ) {
$mod->indexed(0);
Expand Down
6 changes: 6 additions & 0 deletions t/document/file.t
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,12 @@ subtest 'Packages starting with underscore are not indexed' => sub {
is( $file->module->[0]->indexed, 0, 'Package is not indexed' );
};

subtest 'files listed under other files' => sub {
my $file = new_file_doc( name => 'Makefile.PL' );
$file->set_indexed( {} );
is( $file->indexed, 0, 'File listed under other files is not indexed' );
};

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

0 comments on commit 8e15dcb

Please sign in to comment.