Permalink
Browse files

close 164: SIGNATURE files should not be documentation

  • Loading branch information...
1 parent e88b5e3 commit 9163332c9f7798e5a9adee1f6d98370c2f557e05 Chris Nehren committed Apr 1, 2012
Showing with 32 additions and 3 deletions.
  1. +8 −2 lib/MetaCPAN/Document/File.pm
  2. +20 −1 t/release/moose.t
  3. +4 −0 t/var/fakecpan/configs/moose-recent.json
@@ -154,7 +154,7 @@ has module => (
coerce => 1,
clearer => 'clear_module',
lazy => 1,
- default => sub {[]},
+ default => sub { [] },
);
has documentation => (
required => 1,
@@ -269,13 +269,16 @@ Retruns true if the file extension is C<pod>.
=cut
+my @NOT_PERL_FILES = qw(SIGNATURE);
+
sub is_perl_file {
my $self = shift;
return 0 if ( $self->directory );
return 1 if ( $self->name =~ /\.(pl|pm|pod|t)$/i );
return 1 if ( $self->mime eq "text/x-script.perl" );
return 1
if ( $self->name !~ /\./
+ && !grep { $self->name eq $_ } @NOT_PERL_FILES
&& !$self->binary
&& $self->stat->{size} < 2**17 );
return 0;
@@ -338,7 +341,10 @@ sub _build_content {
sub _build_mime {
my $self = shift;
- if ( !$self->directory && $self->name !~ /\./ ) {
+ if ( !$self->directory
+ && $self->name !~ /\./
+ && grep { $self->name ne $_ } @NOT_PERL_FILES )
+ {
my $content = ${ $self->content };
return "text/x-script.perl" if ( $content =~ /^#!.*?perl/ );
}
View
@@ -42,4 +42,23 @@ ok(my $moose = $idx->type('file')->find('Moose'), 'find Moose module');
is($moose->name, 'Moose.pm', 'defined in Moose.pm');
-done_testing;
+my $signature;
+$signature = $idx->type('file')->filter(
+ { and => [
+ { term => { mime => 'text/x-script.perl' } },
+ { term => { name => 'SIGNATURE' } }
+ ]
+ }
+)->first;
+ok(!$signature, 'SIGNATURE is not perl code');
+$signature = $idx->type('file')->filter(
+ { and => [
+ { term => { 'file.documentation' => 'SIGNATURE' } },
+ { term => { mime => 'text/x-script.perl' } },
+ { term => { name => 'SIGNATURE' } }
+ ]
+ }
+)->first;
+ok(!$signature, 'SIGNATURE is not documentation');
+
+done_testing;
@@ -23,6 +23,10 @@
{
"file": "lib/some_script.pl",
"content": "\n\n=head1 NAME\n\nMoose - moose script"
+ },
+ {
+ "file": "SIGNATURE",
+ "content": "A Module::Signature file"
}]
}
}

0 comments on commit 9163332

Please sign in to comment.