Class: Crabfarm::Live::Watcher

Inherits:
Object
  • Object
show all
Defined in:
lib/crabfarm/live/watcher.rb

Constant Summary collapse

PATH_RGX =
/^\/[^\/]+\/(.*?)\.rb$/i

Instance Method Summary collapse

Constructor Details

#initialize(_controller) ⇒ Watcher

Returns a new instance of Watcher.



9
10
11
12
# File 'lib/crabfarm/live/watcher.rb', line 9

def initialize(_controller)
  @controller = _controller
  @candidates = nil
end

Instance Method Details

#watch(_sleep) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
# File 'lib/crabfarm/live/watcher.rb', line 14

def watch(_sleep)
  begin
    start_listener
    loop do
      execute_pending
      sleep _sleep
    end
  ensure
    stop_listener
  end
end