7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
# File 'lib/rspec_runner/watcher.rb', line 7
def start(&block)
if @thread then
raise RuntimeError, "already started"
end
@thread = Thread.new do
config = RspecRunner.configuration
@listener = Listen.to(*config.listen_directories, config.listen_options) do |modified, added, removed|
if((modified.size + added.size + removed.size) > 0)
block.call(modified: modified, added: added, removed: removed)
end
end
@listener.start
puts 'Watcher started!'
end
sleep(0.1) until @listener
at_exit { stop }
@thread
end
|