Class: Crabfarm::Live::Watcher

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

Constant Summary collapse

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

Instance Method Summary collapse

Constructor Details

#initialize(_controller) ⇒ Watcher

Returns a new instance of Watcher.



11
12
13
14
# File 'lib/crabfarm/live/watcher.rb', line 11

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

Instance Method Details

#watch(_sleep) ⇒ Object



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

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