From e19a9304ec9dcdfd463d0ed09a3806c4f4a4ac22 Mon Sep 17 00:00:00 2001 From: Yann Lugrin Date: Sat, 23 Oct 2010 19:33:13 +0800 Subject: [PATCH] Change inotify watch options to not fire event when file is juste read --- lib/guard/listeners/linux.rb | 2 +- spec/guard/listeners/linux_spec.rb | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/guard/listeners/linux.rb b/lib/guard/listeners/linux.rb index a01c5f5..362af1b 100644 --- a/lib/guard/listeners/linux.rb +++ b/lib/guard/listeners/linux.rb @@ -10,7 +10,7 @@ module Guard def on_change(&callback) @callback = callback - inotify.watch(Dir.pwd, :recursive, :attrib, :modify, :create) do |event| + inotify.watch(Dir.pwd, :recursive, :modify, :create, :delete, :move) do |event| unless event.name == "" # Event on root directory @files << event.absolute_name end diff --git a/spec/guard/listeners/linux_spec.rb b/spec/guard/listeners/linux_spec.rb index 25736db..d0f1858 100644 --- a/spec/guard/listeners/linux_spec.rb +++ b/spec/guard/listeners/linux_spec.rb @@ -38,7 +38,7 @@ describe Guard::Linux do file = @fixture_path.join("folder1/file1.txt") File.exists?(file).should be_true start - FileUtils.touch file + File.open(file, 'w') {|f| f.write('') } stop @results.should == ['spec/fixtures/folder1/file1.txt'] end @@ -49,8 +49,8 @@ describe Guard::Linux do File.exists?(file1).should be_true File.exists?(file2).should be_true start - FileUtils.touch file1 - FileUtils.touch file2 + File.open(file1, 'w') {|f| f.write('') } + File.open(file2, 'w') {|f| f.write('') } stop @results.should == ['spec/fixtures/folder1/file1.txt', 'spec/fixtures/folder1/folder2/file2.txt'] end