Skip to content

Commit

Permalink
Documentation and regex simplification.
Browse files Browse the repository at this point in the history
Also, credit Luca Ferrari for the pull requests!
  • Loading branch information
theory committed Jan 8, 2015
1 parent 7b754f3 commit 8e4198a
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 12 deletions.
4 changes: 4 additions & 0 deletions Changes
Expand Up @@ -3,6 +3,10 @@ Change log for Test::Pod
1.49
* Changed license in the README to "Same as Perl" to match the license
listed in `META.yml`, and in the POD as of v1.42.
* Tightened up the heuristic for matching Perl batch files to require
that the file end in `.bat`, as described in the documentation.
Patch from Luca Ferrari.
* Simplified some of the matching code. Patch from Luca Ferrari.

1.48 - 2013-05-06T04:47:00Z
* Fixed test failure with versions of Pod::Simple lower than 3.24. Thanks
Expand Down
21 changes: 9 additions & 12 deletions lib/Test/Pod.pm
Expand Up @@ -156,9 +156,9 @@ so you can't have already called C<plan>.
If C<@entries> is empty or not passed, the function finds all POD files in
files in the F<blib> directory if it exists, or the F<lib> directory if not. A
POD file is one that ends with a Perl extension (F<.pod>, F<.pl>, F<.pm>, F<.PL>, F<.t>),
any file where the first line looks like a Perl-shebang or any batch file (F<.bat>)
starting with a line containing C<--*-Perl-*-->.
POD file is one that ends with a Perl extension (F<.pod>, F<.pl>, F<.pm>,
F<.PL>, F<.t>), where the first line looks like a Perl shebang, or a batch
file (F<.bat>) starting with a line containing C<--*-Perl-*-->.
If you're testing a module, just make a F<t/pod.t>:
Expand Down Expand Up @@ -231,23 +231,19 @@ sub _starting_points {
sub _is_perl {
my $file = shift;


# accept as a Perl file everything that ends with a well known Perl suffix ...
return 1 if $file =~ / [.](?:PL|p(?:[lm]|od)|t)$ /x;
return 1 if $file =~ /[.](?:PL|p(?:[lm]|od)|t)$/;

open my $fh, '<', $file or return;
my $first = <$fh>;
close $fh;

return unless $first;

# ... or that has a she-bang as first line ...
return 1 if defined $first
&& $first =~ /^(?:#!.*perl)/;
return 1 if $first =~ /^#!.*perl/;

# ... or that is a .bat ad has a Perl comment line first
return 1 if defined $first
&& $first =~ /(?:--\*-Perl-\*--)/
&& $file =~ / [.](?:bat) /xi;
return 1 if $file =~ /[.]bat$/i && $first =~ /--[*]-Perl-[*]--/;

return;
}
Expand All @@ -274,8 +270,9 @@ Thanks to
Andy Lester,
David Wheeler,
Paul Miller
Peter Edwards,
and
Peter Edwards
Luca Ferrari
for contributions and to C<brian d foy> for the original code.
=head1 COPYRIGHT AND LICENSE
Expand Down

0 comments on commit 8e4198a

Please sign in to comment.