Sha256: be2b02c6cfee3e7b1dec118406350cc70c1416f16e20bddf5d0e3df79b18db98
Contents?: true
Size: 724 Bytes
Versions: 1
Compression:
Stored size: 724 Bytes
Contents
class FSEvent attr_reader :path, :callback, :pipe def watch(path, &callback) @path = path @callback = callback end def run launch_bin listen end def stop if pipe Process.kill("KILL", pipe.pid) pipe.close end end private def bin_path File.expand_path(File.join(File.dirname(__FILE__), '..', '..', 'bin')) end def launch_bin @pipe = IO.popen("#{bin_path}/fsevent_watch #{path.shellescape}") end def listen while !pipe.eof? if line = pipe.readline modified_dir_paths = line.split(":").select { |dir| dir != "\n" } callback.call(modified_dir_paths) end end rescue Interrupt stop end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
rb-fsevent-0.3.4 | lib/rb-fsevent/fsevent.rb |