Permalink
Browse files

Merge pull request #18 from jonathanperret/fix-script-reparse-on-access

Patch to avoid re-parsing script on atime change
  • Loading branch information...
2 parents 17fa9bf + ec6cdb9 commit 726e61b4fe49c2a99793dd1064c8fc58c88d29b7 @mynyml mynyml committed May 11, 2011
Showing with 9 additions and 1 deletion.
  1. +1 −1 lib/watchr/controller.rb
  2. +8 −0 test/test_controller.rb
@@ -59,7 +59,7 @@ def update(path, event_type = nil)
path = Pathname(path).expand_path
Watchr.debug("received #{event_type.inspect} event for #{path.relative_path_from(Pathname(Dir.pwd))}")
- if path == @script.path
+ if path == @script.path && event_type != :accessed
@script.parse!
@handler.refresh(monitored_paths)
else
@@ -109,5 +109,13 @@ def setup
@handler.stubs(:listen).raises(Interrupt)
@controller.run
end
+
+ test "does not parse script on mere script file access" do
+ path = to_p('abc')
+ @script.stubs(:path).returns(path)
+ @script.expects(:parse!).never
+
+ @controller.update('abc', :accessed)
+ end
end

0 comments on commit 726e61b

Please sign in to comment.