Class: Build::Files::Monitor::FSEvent

Inherits:
Polling
  • Object
show all
Defined in:
lib/build/files/monitor/fsevent.rb

Instance Attribute Summary

Attributes inherited from Polling

#updated

Instance Method Summary collapse

Methods inherited from Polling

#add, #delete, #initialize, #roots, #track_changes, #update

Constructor Details

This class inherits a constructor from Build::Files::Monitor::Polling

Instance Method Details

#run(**options, &block) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/build/files/monitor/fsevent.rb', line 14

def run(**options, &block)
	notifier = ::FSEvent.new
	
	catch(:interrupt) do
		while true
			notifier.watch(self.roots) do |directories|
				directories.collect! do |directory|
					File.expand_path(directory)
				end
				
				self.update(directories)
				
				yield if block_given?
				
				if self.updated
					notifier.stop
				end
			end
			
			notifier.run
		end
	end
end