Created
December 2, 2010 14:37
-
-
Save seanmoon/725428 to your computer and use it in GitHub Desktop.
when used with fsevent_watch.c from autotest, run the command specified in the loop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class FSEventRefresh | |
def initialize | |
@changed = false | |
end | |
def changed? | |
if @changed | |
@changed = false | |
true | |
else | |
false | |
end | |
end | |
def watch(dir) | |
`./bin/fsevent_watch #{dir}` | |
@changed = true | |
self.watch(dir) | |
end | |
end | |
f = FSEventRefresh.new | |
Thread.new do | |
f.watch(ARGV[0]) | |
end | |
f2 = FSEventRefresh.new | |
Thread.new do | |
f2.watch(ARGV[1]) | |
end | |
loop do | |
if f.changed? || f2.changed? | |
IO.popen("echo hello", "r") do |io| | |
io.each_line do |line| | |
puts line | |
end | |
end | |
end | |
Kernel.sleep 0.1 | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment