Class: Alki::Reload::ListenWatcher::Listener

Inherits:
Object
  • Object
show all
Defined in:
lib/alki/reload/listen_watcher.rb

Instance Method Summary collapse

Constructor Details

#initialize(dirs, reloader) ⇒ Listener

Returns a new instance of Listener.



33
34
35
36
37
38
39
40
# File 'lib/alki/reload/listen_watcher.rb', line 33

def initialize(dirs,reloader)
  @count = 0
  @listen = Listen.to(*dirs) do |modified, added, removed|
    if @count > 0 && (modified || added || removed)
      reloader.reload
    end
  end
end

Instance Method Details

#startObject



42
43
44
45
46
47
# File 'lib/alki/reload/listen_watcher.rb', line 42

def start
  if @count == 0
    @listen.start
  end
  @count += 1
end

#stopObject



49
50
51
# File 'lib/alki/reload/listen_watcher.rb', line 49

def stop
  @count -= 1
end