Commits

Shlomi Fish committed d80ffbc

Remove trailing space (with a test).

  • Participants
  • Parent commits c1da57d
  • Tags releases/0.2.6

Comments (0)

Files changed (16)

+0.2.6 - Sun 25 Nov 09:50:22 IST 2012
     - Correct a typo:
         - see https://rt.cpan.org/Ticket/Display.html?id=81428
         - Thanks to Xavier Guimard for the report.
+    - Remove trailing space.
 
 0.2.5 - Thu Jul 12 15:51:56 IDT 2012
     - Add the scripts/tag-release.pl script to tag a release in the
 t/pod-coverage.t
 t/pod.t
 t/sample-data/h.txt
+t/style-trailing-space.t
 META.json
-File::Find::Object is an object-oriented and iterative replacement for 
+File::Find::Object is an object-oriented and iterative replacement for
 File::Find. I.e: it is a module for traversing a directory tree, and finding
 all the files contained within it programatically.
 
 
 Copyright (C) 2005, 2006 by Olivier Thauvin
 
-This package is free software; you can redistribute it and/or modify it under 
+This package is free software; you can redistribute it and/or modify it under
 the following terms:
 
-1. The GNU General Public License Version 2.0 - 
+1. The GNU General Public License Version 2.0 -
 http://www.opensource.org/licenses/gpl-license.php
 
 2. The Artistic License Version 2.0 -

File inc/Test/Run/Builder.pm

         Test::Run::CmdLine::Iface->new(
             {
                 'test_files' => [glob("t/*.t")],
-            }   
+            }
             # 'backend_params' => $self->_get_backend_params(),
         );
 
 sub ACTION_tags
 {
     my $self = shift;
-    return 
+    return
         $self->do_system(
             "ctags",
             qw(-f tags --recurse --totals

File lib/File/Find/Object.pm

 
 use Class::XSAccessor
     accessors => {
-        (map { $_ => $_ } 
+        (map { $_ => $_ }
         (qw(
             _check_subdir_h
             _curr_comps
             _top_is_dir
             _top_is_link
             _top_stat
-            ), 
+            ),
             @{__PACKAGE__->_get_options_ids()}
         )
         )
 sub next_obj {
     my $self = shift;
 
-    until (     $self->_process_current 
+    until (     $self->_process_current
             || ((!$self->_master_move_to_next())
                && $self->_me_die())
             )
     else
     {
         # If depth is false, then we no longer need the _curr_path
-        # of the directories above the previously-set value, because we 
+        # of the directories above the previously-set value, because we
         # already traversed them.
         if ($self->depth())
         {
 {
     my $self = shift;
 
-    $self->_check_subdir() or 
+    $self->_check_subdir() or
         return "SKIP";
 
-    push @{$self->_dir_stack()}, 
+    push @{$self->_dir_stack()},
         $self->_current(
             File::Find::Object::DeepPath->new(
                 $self,
         1;
 }
 
-sub _check_subdir 
+sub _check_subdir
 {
     my $self = shift;
 
     if (!$self->followlink()) {
         push @clauses, '$s->_top_is_link()';
     }
-    
+
     if ($self->nocrossfs()) {
         push @clauses, '($s->_top_stat->[0] != $s->_dev())';
     }
 
     $self->_check_subdir_h(
         _context_less_eval(
-          'sub { my $s = shift; ' 
+          'sub { my $s = shift; '
         . 'return ((!exists($s->{_st})) || !('
         . join("||", @clauses) . '));'
         . '}'
 
 File::Find::Object does the same job as File::Find but works like an object
 and with an iterator. As File::Find is not object oriented, one cannot perform
-multiple searches in the same application. The second problem of File::Find 
-is its file processing: after starting its main loop, one cannot easily wait 
+multiple searches in the same application. The second problem of File::Find
+is its file processing: after starting its main loop, one cannot easily wait
 for another event and so get the next result.
 
-With File::Find::Object you can get the next file by calling the next() 
+With File::Find::Object you can get the next file by calling the next()
 function, but setting a callback is still possible.
 
 =head1 FUNCTIONS
 
     my $ffo = File::Find::Object->new( { options }, @targets);
 
-Create a new File::Find::Object object. C<@targets> is the list of 
+Create a new File::Find::Object object. C<@targets> is the list of
 directories or files which the object should explore.
 
 =head3 options
 
 Boolean - follow symlinks when they point to a directory.
 
-You can safely set this option to true as File::Find::Object does not follow 
+You can safely set this option to true as File::Find::Object does not follow
 the link if it detects a loop.
 
 =item filter
 
-Function reference - should point to a function returning TRUE or FALSE. This 
-function is called with the filename to filter, if the function return FALSE, 
+Function reference - should point to a function returning TRUE or FALSE. This
+function is called with the filename to filter, if the function return FALSE,
 the file is skipped.
 
 =item callback
 
-Function reference - should point to a function, which would be called each 
-time a new file is returned. The function is called with the current filename 
+Function reference - should point to a function, which would be called each
+time a new file is returned. The function is called with the current filename
 as an argument.
 
 =back
 
 =head2 next_obj
 
-Like next() only returns the result as a convenient 
+Like next() only returns the result as a convenient
 L<File::Find::Object::Result> object. C<< $ff->next() >> is equivalent to
 C<< $ff->next_obj()->path() >>.
 
 =head2 item_obj
 
-Like item() only returns the result as a convenient 
+Like item() only returns the result as a convenient
 L<File::Find::Object::Result> object. C<< $ff->item() >> is equivalent to
 C<< $ff->item_obj()->path() >>.
 
 
 Copyright (C) 2005, 2006 by Olivier Thauvin
 
-This package is free software; you can redistribute it and/or modify it under 
+This package is free software; you can redistribute it and/or modify it under
 the following terms:
 
-1. The GNU General Public License Version 2.0 - 
+1. The GNU General Public License Version 2.0 -
 http://www.opensource.org/licenses/gpl-license.php
 
 2. The Artistic License Version 2.0 -

File lib/File/Find/Object/Base.pm

             (qw(
                 _last_dir_scanned
             ))
-        ) 
+        )
     }
     ;
 
 
 Copyright (C) 2005, 2006 by Olivier Thauvin
 
-This package is free software; you can redistribute it and/or modify it under 
+This package is free software; you can redistribute it and/or modify it under
 the following terms:
 
-1. The GNU General Public License Version 2.0 - 
+1. The GNU General Public License Version 2.0 -
 http://www.opensource.org/licenses/gpl-license.php
 
 2. The Artistic License Version 2.0 -

File lib/File/Find/Object/PathComp.pm

                 _stat_ret
                 _traverse_to
             ))
-        ) 
+        )
     },
     getters => { _inodes => '_inodes' },
     setters => { _set_inodes => '_inodes' },
     # $st is an array ref with the return of perldoc -f stat .
     my $st = shift;
 
-    # On MS-Windows, all inodes in stat are returned as 0, so we need to 
-    # check that both inodes are not zero. This is why there's the 
+    # On MS-Windows, all inodes in stat are returned as 0, so we need to
+    # check that both inodes are not zero. This is why there's the
     # $self->_inode() != 0 check at the end.
     return
-    (   
+    (
         $self->_dev() == $st->[0]
      && $self->_inode() == $st->[1]
      && $self->_inode() != 0
     $self->_files($self->_calc_dir_files($dir_str));
 
     $self->_traverse_to($self->_files_copy());
-    
+
     return $self->_open_dir_ret(1);
 }
 
 {
     my $self = shift;
 
-    return shift(@{$self->_traverse_to()}); 
+    return shift(@{$self->_traverse_to()});
 }
 
 1;
 
 =head1 DESCRIPTION
 
-This is the base class for F::F::O's path components. It only defines some 
+This is the base class for F::F::O's path components. It only defines some
 accessors, and is for File::Find::Object's internal use.
 
 =head1 METHODS
 
 Copyright (C) 2005, 2006 by Olivier Thauvin
 
-This package is free software; you can redistribute it and/or modify it under 
+This package is free software; you can redistribute it and/or modify it under
 the following terms:
 
-1. The GNU General Public License Version 2.0 - 
+1. The GNU General Public License Version 2.0 -
 http://www.opensource.org/licenses/gpl-license.php
 
 2. The Artistic License Version 2.0 -

File lib/File/Find/Object/Result.pm

     my $self = shift;
 
     return
-    [ 
+    [
         @{$self->dir_components()},
         ($self->is_dir() ? () : $self->basename()),
     ];
 
 =head2 $result->dir_components()
 
-The components of the directory part of the path starting from base() 
+The components of the directory part of the path starting from base()
 (also the full path if the result is a directory) as an array reference.
 
 =head2 $result->basename()
 =head2 $result->stat_ret()
 
 The return value of L<perlfunc/stat> for the result, placed
-inside an array reference. This is calculated by L<File::Find::Object> and 
+inside an array reference. This is calculated by L<File::Find::Object> and
 kept here for convenience and for internal use.
 
 =head1 SEE ALSO
 
 Copyright (C) 2005, 2006 by Olivier Thauvin
 
-This package is free software; you can redistribute it and/or modify it under 
+This package is free software; you can redistribute it and/or modify it under
 the following terms:
 
-1. The GNU General Public License Version 2.0 - 
+1. The GNU General Public License Version 2.0 -
 http://www.opensource.org/licenses/gpl-license.php
 
 2. The Artistic License Version 2.0 -

File rejects/File/Find/Object.pm

      ;
 }
 
-# This is a variation of the Conditional-to-Inheritance refactoring - 
+# This is a variation of the Conditional-to-Inheritance refactoring -
 # we have two methods - one if _is_top is true
 # and the other if it's false.
 #

File t/02tree-create.t

     ok ($t->exist("./MANIFEST"), "Checking the exist() method");
 
     # TEST
-    ok (!$t->exist("./BKLASDJASFDJODIJASDOJASODJ.wok"), 
+    ok (!$t->exist("./BKLASDJASFDJODIJASDOJASODJ.wok"),
         "Checking the exist() method");
 
     # TEST
 
     # TEST
     ok ($t->is_dir ("./t"), "Checking the is_dir method - true");
-    
+
     # TEST
     is ($t->cat("./t/sample-data/h.txt"), "Hello.",
         "Checking the cat method");
                 {
                     'name' => "b.doc",
                     'contents' => "This file was spotted in the wild.",
-                },            
+                },
                 {
                     'name' => "a/",
                 },
         );
 
         # TEST
-        ok ($t->is_dir("./t/sample-data/tree-test-1/a"), 
+        ok ($t->is_dir("./t/sample-data/tree-test-1/a"),
             "a is a dir"
         );
 

File t/03traverse.t

             {
                 'name' => "b.doc",
                 'contents' => "This file was spotted in the wild.",
-            },            
+            },
             {
                 'name' => "a/",
             },
 
     my $t = File::Find::Object::TreeCreate->new();
     $t->create_tree("./t/sample-data/", $tree);
-    my $ff = 
+    my $ff =
         File::Find::Object->new(
             {},
             $t->get_path("./t/sample-data/traverse-1")
     {
         'name' => "$test_id/",
         'subs' =>
-        [   
+        [
             {
                 'name' => "a/",
                 subs =>
 
     my $t = File::Find::Object::TreeCreate->new();
     $t->create_tree("./t/sample-data/", $tree);
-    my $ff = 
+    my $ff =
         File::Find::Object->new(
             {},
             $t->get_path("./$test_dir/a/b.doc"),
     {
         'name' => "$test_id/",
         'subs' =>
-        [   
+        [
             {
                 'name' => "a/",
                 subs =>
                     },
                 ],
             },
-            
+
             {
                 'name' => "foo/",
                 'subs' =>
 
     my $t = File::Find::Object::TreeCreate->new();
     $t->create_tree("./t/sample-data/", $tree);
-    my $ff = 
+    my $ff =
         File::Find::Object->new(
             {},
             $t->get_path("./$test_dir/foo"),
     {
         'name' => "$test_id/",
         'subs' =>
-        [   
+        [
             {
                 'name' => "a/",
                 subs =>
                     },
                 ],
             },
-            
+
             {
                 'name' => "foo/",
                 'subs' =>
             {
                 'name' => "b.doc",
                 'contents' => "This file was spotted in the wild.",
-            },            
+            },
             {
                 'name' => "a/",
             },
 
     my $t = File::Find::Object::TreeCreate->new();
     $t->create_tree("./t/sample-data/", $tree);
-    my $ff = 
+    my $ff =
         File::Find::Object->new(
             {},
             $t->get_path("./t/sample-data/traverse-1")
         ok (!$r->is_link(), "Not a link");
 
         # TEST
-        is_deeply ($r->full_components(), [qw(b.doc)], 
+        is_deeply ($r->full_components(), [qw(b.doc)],
             "Full components are 'b.doc'"
         );
 
         is ($r->base(), $t->get_path("./t/sample-data/traverse-1"), "Base");
 
         # TEST
-        is_deeply ($r->dir_components(), [qw(foo)], 
+        is_deeply ($r->dir_components(), [qw(foo)],
             "Dir_Components are 'foo'"
         );
 
         ok ($r->is_dir(), "Is a directory");
 
         # TEST
-        is_deeply ($r->full_components(), [qw(foo)], 
+        is_deeply ($r->full_components(), [qw(foo)],
             "Full components are 'foo'"
         );
     }
         my $r = $ff->next_obj();
 
         # TEST
-        is ($r->path(), $t->get_path("t/sample-data/traverse-1/foo/file.txt"), 
+        is ($r->path(), $t->get_path("t/sample-data/traverse-1/foo/file.txt"),
             "Path",
         );
 
         # TEST
-        is ($r->base(), $t->get_path("./t/sample-data/traverse-1"), 
+        is ($r->base(), $t->get_path("./t/sample-data/traverse-1"),
             "Base"
         );
 
         # TEST
-        is_deeply ($r->dir_components(), [qw(foo)], 
+        is_deeply ($r->dir_components(), [qw(foo)],
             "Dir_Components are 'foo'"
         );
 
         ok (!$r->is_dir(), "Not a directory");
 
         # TEST
-        is_deeply ($r->full_components(), [qw(foo file.txt)], 
+        is_deeply ($r->full_components(), [qw(foo file.txt)],
             "Full components are 'foo/file.txt'"
         );
 
         my $r = $ff->next_obj();
 
         # TEST
-        is ($r->path(), $t->get_path("t/sample-data/traverse-1/foo/yet"), 
+        is ($r->path(), $t->get_path("t/sample-data/traverse-1/foo/yet"),
             "Path",
         );
 
         is ($r->base(), $t->get_path("./t/sample-data/traverse-1"), "Base");
 
         # TEST
-        is_deeply ($r->dir_components(), [qw(foo yet)], 
+        is_deeply ($r->dir_components(), [qw(foo yet)],
             "Dir_Components are 'foo/yet'"
         );
 
         ok ($r->is_dir(), "Is a directory");
 
         # TEST
-        is_deeply ($r->full_components(), [qw(foo yet)], 
+        is_deeply ($r->full_components(), [qw(foo yet)],
             "Full components are 'foo/yet'"
         );
     }
                         'name' => "2",
                         'contents' => "Two file",
                     },
-                    
+
 
                 ],
             },
             {
                 'name' => "b.doc",
                 'contents' => "This file was spotted in the wild.",
-            },            
+            },
             {
                 'name' => "a/",
             },
         ok ($path_obj->is_dir(), "Path object is a directory");
     };
 
-    $ff = 
+    $ff =
         File::Find::Object->new(
             {callback => $callback},
             $t->get_path("./t/sample-data/traverse-1")
             {
                 'name' => "b.doc",
                 'contents' => "This file was spotted in the wild.",
-            },            
+            },
             {
                 'name' => "a/",
             },
 
     my $t = File::Find::Object::TreeCreate->new();
     $t->create_tree("./t/sample-data/", $tree);
-    my $ff = 
+    my $ff =
         File::Find::Object->new(
             {nocrossfs => 1,},
             $t->get_path("./t/sample-data/traverse-1")
             {
                 'name' => "b.doc",
                 'contents' => "This file was spotted in the wild.",
-            },            
+            },
             {
                 'name' => "a/",
             },
 
     my $t = File::Find::Object::TreeCreate->new();
     $t->create_tree("./t/sample-data/", $tree);
-    my $ff = 
+    my $ff =
         File::Find::Object->new(
             {},
             $t->get_path("./t/sample-data/traverse-1")

File t/04destroy.t

             {
                 'name' => "b.doc",
                 'contents' => "This file was spotted in the wild.",
-            },            
+            },
             {
                 'name' => "a/",
             },
 
     my $t = File::Find::Object::TreeCreate->new();
     $t->create_tree("./t/sample-data/", $tree);
-    my $ff = 
+    my $ff =
         MyFFO->new(
             {},
             $t->get_path("./t/sample-data/traverse-1")
             {
                 'name' => "b.doc",
                 'contents' => "This file was spotted in the wild.",
-            },            
+            },
             {
                 'name' => "a/",
             },
                                         'name' => "dir2/",
                                     },
                                     {
-                                        'name' => 
+                                        'name' =>
                                             "if-we-get-this-its-wrong.txt",
                                         'content' => "Hi ho!",
                                     },
                                 ],
-                            },                        
+                            },
                             {
                                 'name' => "h.rnd",
                                 'contents' => "This file is empty.",
 
     my $t = File::Find::Object::TreeCreate->new();
     $t->create_tree("./t/sample-data/", $tree);
-    my $ff = 
+    my $ff =
         File::Find::Object->new(
             {},
             $t->get_path("./t/sample-data/traverse-2")
         # We're doing that because get_current_node_files_list() used to
         # call ->_recurse() which caused some subtle bugs.
         my $files_in_node = $ff->get_current_node_files_list();
-        
+
         if ($file eq
             $t->get_path("t/sample-data/traverse-2/foo/please-prune-me")
            )
         {
             $ff->set_traverse_to(
                 [
-                    grep { $_ !~ /non-reachable/ } 
+                    grep { $_ !~ /non-reachable/ }
                     @{$ff->get_current_node_files_list()}
                 ]
             );
     is_deeply(
         \@results,
         [(map { $t->get_path("t/sample-data/traverse-2/$_") }
-            ("", 
+            ("",
             qw(
                 a
                 b.doc
             {
                 'name' => "b.doc",
                 'contents' => "This file was spotted in the wild.",
-            },            
+            },
             {
                 'name' => "a/",
             },
                                         'name' => "dir2/",
                                     },
                                     {
-                                        'name' => 
+                                        'name' =>
                                             "if-we-get-this-its-wrong.txt",
                                         'content' => "Hi ho!",
                                     },
                                 ],
-                            },                        
+                            },
                             {
                                 'name' => "h.rnd",
                                 'contents' => "This file is empty.",
 
     my $t = File::Find::Object::TreeCreate->new();
     $t->create_tree("./t/sample-data/", $tree);
-    my $ff = 
+    my $ff =
         File::Find::Object->new(
             {},
             $t->get_path("./t/sample-data/traverse-2")
     for my $i (1 .. 9)
     {
         my $file = $ff->next();
-        if ($file eq 
+        if ($file eq
             $t->get_path("t/sample-data/traverse-2/foo/please-prune-me")
            )
         {
     is_deeply(
         \@results,
         [(map { $t->get_path("t/sample-data/traverse-2/$_") }
-            ("", 
+            ("",
             qw(
                 a
                 b.doc

File t/06trailing-slash.t

 use File::Path;
 
 {
-    my $ff = 
+    my $ff =
         File::Find::Object->new(
             {},
             "t/",

File t/lib/File/Find/Object/TreeCreate.pm

     {
         push @components, File::Spec->curdir();
     }
-    
+
     my $is_dir = ($path =~ s{/$}{});
     push @components, split(/\//, $path);
     if ($is_dir)
     my $self = shift;
     opendir my $dir, $self->get_path(@_) or
         return undef;
-    my @files = 
-        sort { $a cmp $b } 
+    my @files =
+        sort { $a cmp $b }
         grep { !(($_ eq ".") || ($_ eq "..")) }
         readdir($dir);
-    closedir($dir);    
+    closedir($dir);
     return \@files;
 }
 

File t/style-trailing-space.t

+#!/usr/bin/perl
+
+use strict;
+use warnings;
+
+use Test::More;
+
+eval "use Test::TrailingSpace";
+if ($@)
+{
+   plan skip_all => "Test::TrailingSpace required for trailing space test.";
+}
+else
+{
+   plan tests => 1;
+}
+
+# TODO: add .pod, .PL, the README/Changes/TODO/etc. documents and possibly
+# some other stuff.
+my $finder = Test::TrailingSpace->new(
+   {
+       root => '.',
+       filename_regex => qr/(?:\.(?:t|pm|pl|xs|c|h|txt|pod|PL)|README|Changes|TODO|LICENSE)\z/,
+   },
+);
+
+# TEST
+$finder->no_trailing_space(
+   "No trailing space was found."
+);