Permalink
Browse files

Merge pull request #359 from nihen/vim_swap

ignore vim swap and temp files on restarter
  • Loading branch information...
2 parents 7b1ee71 + e405a4d commit 9ac91686e3ba402181950e544044a77e34238022 @miyagawa miyagawa committed Jan 31, 2013
Showing with 16 additions and 3 deletions.
  1. +7 −1 lib/Plack/Loader/Restarter.pm
  2. +9 −2 t/Plack-Loader/restarter_valid.t
@@ -46,7 +46,13 @@ sub _kill_child {
sub valid_file {
my($self, $file) = @_;
- $file->{path} !~ m!\.(?:git|svn)[/\\]|\.(?:bak|swp)$|~$|_flymake\.p[lm]!;
+
+ # vim temporary file is 4913 to 5036
+ # http://www.mail-archive.com/vim_dev@googlegroups.com/msg07518.html
+ if ( $file->{path} =~ m{(\d+)$} && $1 >= 4913 && $1 <= 5036) {
+ return 0;
+ }
+ $file->{path} !~ m!\.(?:git|svn)[/\\]|\.(?:bak|swp|swpx|swx)$|~$|_flymake\.p[lm]$!;
}
sub run {
@@ -4,8 +4,15 @@ use Test::More;
my $r = Plack::Loader::Restarter->new;
-my @match = qw(Foo.pm foo.t lib/Bar.pm view/index.tt _myapp/foo.psgi .www/bar.pl _sass.css /Users/joe/foo/bar.pm);
-my @ignore = qw(.git/123 .svn/abc Foo.pm~ _flymake.pl /Users/joe/foo.pl~ /foo/bar/x.txt.bak);
+my @match = qw(
+ Foo.pm foo.t lib/Bar.pm view/index.tt _myapp/foo.psgi .www/bar.pl _sass.css /Users/joe/foo/bar.pm
+ /path/to/4912 /path/to/5037
+);
+my @ignore = qw(
+ .git/123 .svn/abc Foo.pm~ _flymake.pl /Users/joe/foo.pl~ /foo/bar/x.txt.bak
+ /path/to/foo.swp /path/to/foo.swpx /path/to/foo.swx
+ /path/to/4913 /path/to/5036
+);
ok $r->valid_file({ path => $_ }), "$_ is valid" for @match;
ok !$r->valid_file({ path => $_ }), "$_ should be ignored" for @ignore;

0 comments on commit 9ac9168

Please sign in to comment.