class FSSM::Backends::RBFSEvent
Public Class Methods
new()
click to toggle source
# File lib/fssm/backends/rbfsevent.rb, line 3 def initialize @handlers = [] end
Public Instance Methods
add_handler(handler, preload=true)
click to toggle source
# File lib/fssm/backends/rbfsevent.rb, line 7 def add_handler(handler, preload=true) @handlers << handler handler.refresh(nil, true) if preload end
run()
click to toggle source
# File lib/fssm/backends/rbfsevent.rb, line 12 def run begin @fsevent = FSEvent.new @fsevent.watch(temporary_multipath_hack) do |paths| paths.each do |path| temporary_multipath_handler(path) end end @fsevent.run rescue Interrupt @fsevent.stop end end
temporary_multipath_hack()
click to toggle source
# File lib/fssm/backends/rbfsevent.rb, line 36 def temporary_multipath_hack @handlers = @handlers.sort {|x,y| y.path.to_pathname.segments.length <=> x.path.to_pathname.segments.length} return @handlers.map {|handler| handler.path.to_s} end
temporary_multipath_handler(path)
click to toggle source
# File lib/fssm/backends/rbfsevent.rb, line 26 def temporary_multipath_handler(path) @handlers.each do |handler| handler_path = File.join(handler.path.to_s, "") if path.start_with?(handler_path) handler.refresh(path) break end end end