Skip to content

Commit

Permalink
Improve INotify support on linux (fixes guard#79 guard#82)
Browse files Browse the repository at this point in the history
Improve usage with several text editors that writes to temporal
files and then move over the original filename instead of write
files directly. Tested with GEdit, Nano, vim (with 'set backup'
and 'set nobackup') and emacs.
  • Loading branch information
Gazer authored and yannlugrin committed Jun 17, 2011
1 parent 975444b commit d51b457
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/guard/listeners/linux.rb
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def worker
end end


def watch(directory) def watch(directory)
worker.watch(directory, :recursive, :modify, :create) do |event| worker.watch(directory, :recursive, :modify, :create, :close_write) do |event|
unless event.name == "" # Event on root directory unless event.name == "" # Event on root directory
@files << event.absolute_name @files << event.absolute_name
end end
Expand Down
11 changes: 11 additions & 0 deletions spec/guard/listeners/linux_spec.rb
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -50,6 +50,17 @@


# Fun fact: File.touch seems not to be enough on Linux to trigger a modify event # Fun fact: File.touch seems not to be enough on Linux to trigger a modify event


it "catches a write_close event" do
@listener = described_class.new
record_results
file = @fixture_path.join("folder1/file1.txt")
File.exists?(file).should be_true
start
File.open(file, 'r+').close
stop
results.should =~ ['spec/fixtures/folder1/file1.txt']
end

it "doesn't process a change when it is stopped" do it "doesn't process a change when it is stopped" do
@listener = described_class.new @listener = described_class.new
record_results record_results
Expand Down

0 comments on commit d51b457

Please sign in to comment.