Skip to content

Commit 7a3bea6

Browse files
committed
exclude inc and local directories from indexing
1 parent f414c2a commit 7a3bea6

File tree

2 files changed

+33
-15
lines changed

2 files changed

+33
-15
lines changed

lib/MetaCPAN/Document/File.pm

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -615,16 +615,21 @@ sub is_pod_file {
615615
shift->name =~ /\.pod$/i;
616616
}
617617

618-
=head2 is_in_test_directory
618+
=head2 is_in_excluded_directory
619619
620-
Returns true if the file is below a t directory.
620+
Returns true if the file is below an excluded directory.
621621
622622
=cut
623623

624-
sub is_in_test_directory {
625-
my $self = shift;
626-
my @parts = split m{/}, $self->path;
627-
return any { $_ eq 't' } @parts;
624+
sub is_in_excluded_directory {
625+
my $self = shift;
626+
my @excluded = qw[t inc local];
627+
my @parts = split m{/}, $self->path;
628+
return any {
629+
my $part = $_;
630+
any { $_ eq $part } @excluded;
631+
}
632+
@parts;
628633
}
629634

630635
=head2 add_module
@@ -664,7 +669,7 @@ does not include any modules, the L</indexed> property is true.
664669
sub set_indexed {
665670
my ( $self, $meta ) = @_;
666671

667-
if ( $self->is_in_test_directory() ) {
672+
if ( $self->is_in_excluded_directory() ) {
668673
foreach my $mod ( @{ $self->module } ) {
669674
$mod->indexed(0);
670675
}

t/document/file.t

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,19 +13,32 @@ my %stub = (
1313
);
1414

1515
{
16-
my @test_paths = qw( t/whomp foo/t/bar cuppa/t );
17-
my @non_test_paths = qw( foo/bart/shorts tit/mouse say/wat );
16+
my @excluded_paths = qw(
17+
t/whomp
18+
foo/t/bar
19+
cuppa/t
20+
conv/inc/ing
21+
buy/local/beer
22+
);
23+
24+
my @non_excluded_paths = qw(
25+
foo/bart/shorts
26+
tit/mouse
27+
say/wat
28+
wince/inducing/module
29+
not/locally/made
30+
);
1831

19-
foreach my $path (@test_paths) {
32+
foreach my $path (@excluded_paths) {
2033
my $file = MetaCPAN::Document::File->new( %stub, path => $path );
21-
my $msg = "$path is in a test directory";
22-
ok( $file->is_in_test_directory(), $msg );
34+
my $msg = "$path is in an excluded directory";
35+
ok( $file->is_in_excluded_directory(), $msg );
2336
}
2437

25-
foreach my $path (@non_test_paths) {
38+
foreach my $path (@non_excluded_paths) {
2639
my $file = MetaCPAN::Document::File->new( %stub, path => $path );
27-
my $msg = "$path is not in a test directory";
28-
ok( !$file->is_in_test_directory(), $msg );
40+
my $msg = "$path is not in an excluded directory";
41+
ok( !$file->is_in_excluded_directory(), $msg );
2942
}
3043
}
3144

0 commit comments

Comments
 (0)