[Bps-public-commit] Test-Spelling branch, master, updated. 56e7ad3f67e7a33e8dfbd5a0505f0136706340a9

Shawn Moore sartak at bestpractical.com
Mon Apr 25 13:12:49 EDT 2011


The branch, master has been updated
       via  56e7ad3f67e7a33e8dfbd5a0505f0136706340a9 (commit)
      from  45f7e77d4c4072b7ffdc7e591196317a4916b312 (commit)

Summary of changes:
 Changes              |    2 ++
 lib/Test/Spelling.pm |   27 ++++++++++++++++++++++++++-
 2 files changed, 28 insertions(+), 1 deletions(-)

- Log -----------------------------------------------------------------
commit 56e7ad3f67e7a33e8dfbd5a0505f0136706340a9
Author: Shawn M Moore <sartak at bestpractical.com>
Date:   Mon Apr 25 13:04:34 2011 -0400

    Support for filtering certain pod files, set_pod_file_filter [rt.cpan.org #63755]

diff --git a/Changes b/Changes
index 246004e..0609f2b 100644
--- a/Changes
+++ b/Changes
@@ -6,6 +6,8 @@ Revision history for Test-Spelling
           (reported by Tokuhiro Matsuno)
         - Correct aspell suggestion from -l to list [rt.cpan.org #28967]
           (reported by David Hand)
+        - Add set_pod_file_filter for skipping translations, etc.
+          [rt.cpan.org #63755] (reported by me :))
 
 0.11  2005-11-15
         - Some documentation fixes.
diff --git a/lib/Test/Spelling.pm b/lib/Test/Spelling.pm
index 8046806..2680c6c 100644
--- a/lib/Test/Spelling.pm
+++ b/lib/Test/Spelling.pm
@@ -16,12 +16,14 @@ our @EXPORT = qw(
     add_stopwords
     set_spell_cmd
     all_pod_files
+    set_pod_file_filter
 );
 
 our $VERSION = '0.11';
 
 my $Test        = Test::Builder->new;
 my $Spell_cmd   = 'spell';
+my $file_filter = sub { 1 };
 
 sub pod_file_spelling_ok {
     my $file = shift;
@@ -92,7 +94,9 @@ sub all_pod_files {
             push @queue, map "$file/$_", @newfiles;
         }
         if ( -f $file ) {
-            push @pod, $file if _is_perl( $file );
+            next unless !_is_perl($file);
+            next unless $file_filter->($file);
+            push @pod, $file;
         }
     } # while
     return @pod;
@@ -135,6 +139,10 @@ sub set_spell_cmd {
     $Spell_cmd = shift;
 }
 
+sub set_pod_file_filter {
+    $file_filter = shift;
+}
+
 1;
 
 __END__
@@ -232,6 +240,9 @@ A Perl file is:
 
 =back
 
+Furthermore, files for which the filter set by L</set_pod_file_filter> return
+false are skipped. By default this filter passes everything through.
+
 The order of the files returned is machine-dependent.  If you want them
 sorted, you'll have to sort them yourself.
 
@@ -275,6 +286,20 @@ specify an alternative with C<set_spell_cmd>. Any command that takes text
 from standard input and prints a list of misspelled words, one per line, to
 standard output will do. For example, you can use C<aspell list>.
 
+=head2 set_pod_file_filter($code)
+
+If your project has POD documents written in languages other than English, then
+obviously you don't want to be running a spellchecker on every Perl file.
+C<set_pod_file_filter> lets you filter out files returned from
+L</all_pod_files> (and hence, the documents tested by
+L</all_pod_files_spelling_ok>).
+
+    set_pod_file_filter(sub {
+        my $filename = shift;
+        return 0 if $filename =~ /_ja.pod$/; # skip Japanese translations
+        return 1;
+    });
+
 =head1 SEE ALSO
 
 L<Pod::Spell>

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



More information about the Bps-public-commit mailing list