Class: Kaisoku::WatchSession
- Inherits:
-
Object
- Object
- Kaisoku::WatchSession
- Defined in:
- lib/kaisoku/watch_session.rb
Instance Method Summary collapse
-
#initialize(watcher:, runner:, debounce: 0.05) ⇒ WatchSession
constructor
A new instance of WatchSession.
- #start ⇒ Object
Constructor Details
#initialize(watcher:, runner:, debounce: 0.05) ⇒ WatchSession
Returns a new instance of WatchSession.
5 6 7 8 9 10 |
# File 'lib/kaisoku/watch_session.rb', line 5 def initialize(watcher:, runner:, debounce: 0.05) @watcher = watcher @debounce = debounce.to_f @runner = runner @current_pid = nil end |
Instance Method Details
#start ⇒ Object
12 13 14 15 16 17 18 19 20 21 |
# File 'lib/kaisoku/watch_session.rb', line 12 def start @watcher.each_change do |changed_paths| sleep @debounce cancel_current @current_pid = fork { exit!(@runner.call(changed_paths).to_i) } Process.detach(@current_pid) end ensure cancel_current end |