Skip to content

Instantly share code, notes, and snippets.

@seanmoon
Created December 2, 2010 14:37
Show Gist options
  • Save seanmoon/725428 to your computer and use it in GitHub Desktop.
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.
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