Skip to content

Commit

Permalink
controller.rb : prevent re-parsing the script when only its access ti…
Browse files Browse the repository at this point in the history
…me changes.
  • Loading branch information
jperret committed Dec 31, 2010
1 parent 17fa9bf commit ec6cdb9
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/watchr/controller.rb
Expand Up @@ -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
Expand Down
8 changes: 8 additions & 0 deletions test/test_controller.rb
Expand Up @@ -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.