Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Use File::Find.

  • Loading branch information...
commit 45b34ba20a1d64e1600c90f54a64234ae198887a 1 parent e70eef1
@theory theory authored
Showing with 11 additions and 32 deletions.
  1. +1 −1  Build.PL
  2. +2 −0  Changes
  3. +8 −31 lib/Test/Pod.pm
View
2  Build.PL
@@ -13,7 +13,7 @@ Module::Build->new(
'Test::More' => '0.62',
},
requires => {
- 'File::Spec' => 0,
+ 'File::Find' => 0,
'Pod::Simple' => '3.05',
'Test::Builder::Tester' => '1.02',
'Test::More' => '0.62',
View
2  Changes
@@ -3,6 +3,8 @@ Change log for Test::Pod
1.46
* Fixed a crash when `all_pod_files_ok()` finds no files to test. Thanks
to H.Merijn Brand.
+ * Switched from custom file searching code to File::Find. Suggested by
+ H.Merijn Brand.
1.45 2011-03-09T20:00:59
* Removed Module::Build from `build_requires`, since it does nothing
View
39 lib/Test/Pod.pm
@@ -64,7 +64,6 @@ C<Pod::Simple> to do the heavy lifting.
use 5.008;
use Test::Builder;
-use File::Spec;
use Pod::Simple;
our %ignore_dirs = (
@@ -193,8 +192,8 @@ sub all_pod_files_ok {
Returns a list of all the Perl files in I<@dirs> and in directories below. If
no directories are passed, it defaults to F<blib> if F<blib> exists, or else
-F<lib> if not. Skips any files in CVS, .svn, .git and similar directories. See
-C<%Test::Pod::ignore_dirs> for a list of them.
+F<lib> if not. Skips any files in F<CVS>, F<.svn>, F<.git> and similar
+directories. See C<%Test::Pod::ignore_dirs> for a list of them.
A Perl file is:
@@ -214,34 +213,12 @@ sorted, you'll have to sort them yourself.
=cut
sub all_pod_files {
- my @queue = @_ ? @_ : _starting_points();
- my @pod = ();
-
- while ( @queue ) {
- my $file = shift @queue;
- if ( -d $file ) {
- local *DH;
- opendir DH, $file or next;
- my @newfiles = readdir DH;
- closedir DH;
-
- @newfiles = File::Spec->no_upwards( @newfiles );
- @newfiles = grep { not exists $ignore_dirs{ $_ } } @newfiles;
-
- foreach my $newfile (@newfiles) {
- my $filename = File::Spec->catfile( $file, $newfile );
- if ( -f $filename ) {
- push @queue, $filename;
- }
- else {
- push @queue, File::Spec->catdir( $file, $newfile );
- }
- }
- }
- if ( -f $file ) {
- push @pod, $file if _is_perl( $file );
- }
- } # while
+ my @pod;
+ require File::Find;
+ File::Find::find({
+ wanted => sub { -f $_ && _is_perl ($_) and push @pod, $File::Find::name },
+ no_chdir => 1,
+ }, @_ ? @_ : _starting_points());
return @pod;
}
Please sign in to comment.
Something went wrong with that request. Please try again.