[Bps-public-commit] Test-Spelling branch, master, updated. 39cd8b10de5093bcbb6bca5f37b3cdb5e9816a6c

Shawn Moore sartak at bestpractical.com
Mon Apr 25 13:37:50 EDT 2011


The branch, master has been updated
       via  39cd8b10de5093bcbb6bca5f37b3cdb5e9816a6c (commit)
       via  c266e00c76bc1eae5eee9ce44e5fc6f755a063f6 (commit)
      from  31fca522eefe2ed94d228de1a1210608aa174e4d (commit)

Summary of changes:
 lib/Test/Spelling.pm |   42 ++++++++++++++++++++++--------------------
 1 files changed, 22 insertions(+), 20 deletions(-)

- Log -----------------------------------------------------------------
commit c266e00c76bc1eae5eee9ce44e5fc6f755a063f6
Author: Shawn M Moore <sartak at bestpractical.com>
Date:   Mon Apr 25 13:35:00 2011 -0400

    More substantial cleanup

diff --git a/lib/Test/Spelling.pm b/lib/Test/Spelling.pm
index cd81651..203c5f9 100644
--- a/lib/Test/Spelling.pm
+++ b/lib/Test/Spelling.pm
@@ -46,11 +46,11 @@ sub invalid_words_in {
 
 sub pod_file_spelling_ok {
     my $file = shift;
-    my $name = @_ ? shift : "POD spelling for $file";
+    my $name = shift || "POD spelling for $file";
 
-    if (!-f $file) {
+    if (!-r $file) {
         $Test->ok(0, $name);
-        $Test->diag("$file does not exist");
+        $Test->diag("$file does not exist or is unreadable");
         return;
     }
 
@@ -60,13 +60,13 @@ sub pod_file_spelling_ok {
     @words = grep { !$Pod::Wordlist::Wordlist{$_} } @words;
     my %seen;
     @seen{@words} = ();
-    @words = map "    $_\n", sort keys %seen;
+    @words = sort keys %seen;
 
     # emit output
-    my $ok = !@words;
+    my $ok = @words == 0;
     $Test->ok($ok, "$name");
     if (!$ok) {
-        $Test->diag("Errors:\n" . join '', @words);
+        $Test->diag("Errors:\n" . join '', map { "    $_\n" } @words);
     }
 
     return $ok;
@@ -90,9 +90,11 @@ sub all_pod_files {
 
     while (@queue) {
         my $file = shift @queue;
+
+        # recurse into subdirectories
         if (-d $file) {
-            opendir my $dirhandle, $file or next;
-            my @newfiles = readdir $dirhandle;
+            opendir(my $dirhandle, $file) or next;
+            my @newfiles = readdir($dirhandle);
             closedir $dirhandle;
 
             @newfiles = File::Spec->no_upwards(@newfiles);
@@ -100,17 +102,20 @@ sub all_pod_files {
 
             push @queue, map "$file/$_", @newfiles;
         }
+
+        # add the file if it meets our criteria
         if (-f $file) {
             next unless _is_perl($file);
             next unless $file_filter->($file);
             push @pod, $file;
         }
-    } # while
+    }
+
     return @pod;
 }
 
 sub _starting_points {
-    return 'blib' if -e 'blib';
+    return 'blib' if -d 'blib';
     return 'lib';
 }
 
@@ -121,19 +126,16 @@ sub _is_perl {
     return 1 if $file =~ /\.p(l|m|od)$/;
     return 1 if $file =~ /\.t$/;
 
-    local *FH;
-    open FH, $file or return;
-    my $first = <FH>;
-    close FH;
+    open my $handle, '<', $file or return;
+    my $first = <$handle>;
 
     return 1 if defined $first && ($first =~ /^#!.*perl/);
 
-    return;
+    return 0;
 }
 
 sub add_stopwords {
-    for (@_) {
-        my $word = $_;
+    for my $word (@_) {
         $word =~ s/^#?\s*//;
         $word =~ s/\s+$//;
         next if $word =~ /\s/ or $word =~ /:/;

commit 39cd8b10de5093bcbb6bca5f37b3cdb5e9816a6c
Author: Shawn M Moore <sartak at bestpractical.com>
Date:   Mon Apr 25 13:37:36 2011 -0400

    Add .plx to pod spell tests (you're welcome Schwern)

diff --git a/lib/Test/Spelling.pm b/lib/Test/Spelling.pm
index 203c5f9..30b4e5a 100644
--- a/lib/Test/Spelling.pm
+++ b/lib/Test/Spelling.pm
@@ -123,7 +123,7 @@ sub _is_perl {
     my $file = shift;
 
     return 1 if $file =~ /\.PL$/;
-    return 1 if $file =~ /\.p(l|m|od)$/;
+    return 1 if $file =~ /\.p(l|lx|m|od)$/;
     return 1 if $file =~ /\.t$/;
 
     open my $handle, '<', $file or return;
@@ -221,8 +221,8 @@ each function), so you can't have already called C<plan>.
 
 If C<@files> is empty or not passed, the function finds all POD files in
 the F<blib> directory if it exists, or the F<lib> directory if not.
-A POD file is one that ends with F<.pod>, F<.pl> and F<.pm>, or any file
-where the first line looks like a shebang line.
+A POD file is one that ends with F<.pod>, F<.pl>, F<.plx> and F<.pm>, or any
+file where the first line looks like a shebang line.
 
 If you're testing a module, just make a F<t/spell.t>:
 

-----------------------------------------------------------------------



More information about the Bps-public-commit mailing list