Class: Kicker::FSEvents

Inherits:
Object
  • Object
show all
Defined in:
lib/kicker/fsevents.rb

Defined Under Namespace

Classes: FSEvent

Class Method Summary collapse

Class Method Details

.start_watching(paths, options = {}, &block) ⇒ Object



25
26
27
28
29
30
31
32
33
34
# File 'lib/kicker/fsevents.rb', line 25

def self.start_watching(paths, options={}, &block)
  listener = Listen.to(*(paths.dup << options))
  listener.change do |modified, added, removed|
    files = modified + added + removed
    directories = files.map { |file| File.dirname(file) }.uniq
    yield directories.map { |directory| Kicker::FSEvents::FSEvent.new(directory) }
  end
  listener.start
  listener
end