Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Patch to avoid re-parsing script on atime change #18

Merged
merged 1 commit into from

3 participants

@jonathanperret

Hi, here's a small fix for that issue.
My scripts usually do an action (like run tests a first time) when parsed, and I was getting tired of that getting run twice when I changed the script.
I'm running watchr under Windows btw. And I love it !
-Jonathan

@mynyml mynyml merged commit 726e61b into mynyml:master
@mynyml
Owner

So I think this breaks backward compatibility because in theory you could register watches on :access events. But I'd be surprised if anyone used that.

I'm hoping to find some time to get rid of the event type feature altogether in favor of something simpler like providing prev_time and curr_time directly.

Thanks for the patch. Sorry for the delay.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Dec 31, 2010
This page is out of date. Refresh to see the latest.
Showing with 9 additions and 1 deletion.
  1. +1 −1  lib/watchr/controller.rb
  2. +8 −0 test/test_controller.rb
View
2  lib/watchr/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
View
8 test/test_controller.rb
@@ -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
Something went wrong with that request. Please try again.