compass/lib/vendor/fssm/backends/fsevents.rb

38 lines
765 B
Ruby
Raw Normal View History

require File.join(File.dirname(__FILE__), 'rubycocoa/fsevents')
2009-09-03 05:42:59 +00:00
module FSSM::Backends
2009-09-03 05:42:59 +00:00
class FSEvents
def initialize
@handlers = {}
@fsevents = []
end
def add_path(path, preload=true)
handler = FSSM::State.new(path)
2009-09-03 05:42:59 +00:00
@handlers["#{path}"] = handler
fsevent = Rucola::FSEvents.new("#{path}", {:latency => 0.5}) do |events|
2009-09-03 05:42:59 +00:00
events.each do |event|
handler.refresh(event.path)
end
end
2009-09-03 05:42:59 +00:00
fsevent.create_stream
handler.refresh(path.to_pathname, true) if preload
2009-09-03 05:42:59 +00:00
fsevent.start
@fsevents << fsevent
end
def run
begin
OSX.CFRunLoopRun
rescue Interrupt
2009-09-03 05:42:59 +00:00
@fsevents.each do |fsev|
fsev.stop
end
end
end
2009-09-03 05:42:59 +00:00
end
end