Permalink
Browse files

controller.rb : prevent re-parsing the script when only its access ti…

…me changes.
  • Loading branch information...
1 parent 17fa9bf commit ec6cdb9928467cf67c18bc1a9e1bb327b551df9b jperret committed Dec 31, 2010
Showing with 9 additions and 1 deletion.
  1. +1 −1 lib/watchr/controller.rb
  2. +8 −0 test/test_controller.rb
View
@@ -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
View
@@ -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 ec6cdb9

Please sign in to comment.