Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Documentation and regex simplification.

Also, credit Luca Ferrari for the pull requests!
  • Loading branch information...
commit 8e4198aba14f9550328ef9bc051f35a0384ebeb2 1 parent 7b754f3
@theory authored
Showing with 13 additions and 12 deletions.
  1. +4 −0 Changes
  2. +9 −12 lib/Test/Pod.pm
View
4 Changes
@@ -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
View
21 lib/Test/Pod.pm
@@ -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>:
@@ -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;
}
@@ -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
Please sign in to comment.
Something went wrong with that request. Please try again.