Class: Build::Files::Monitor::Native
- Defined in:
- lib/build/files/monitor/native.rb
Overview
A platform-specific filesystem monitor using native OS APIs.
This implementation uses platform-specific APIs (FSEvent on macOS, INotify on Linux) for efficient, event-driven file monitoring. It extends Polling but replaces the polling mechanism with native filesystem events.
Instance Attribute Summary
Attributes inherited from Polling
Instance Method Summary collapse
- 
  
    
      #run(**options, &block)  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    Run the monitor using native filesystem events. 
- 
  
    
      #run_roots(roots, **options, &block)  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    Monitor the specified roots for changes using native events. 
Methods inherited from Polling
#Whether the set of monitored directories has been updated.=, #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
Run the monitor using native filesystem events.
This method blocks until interrupted via ‘throw :interrupt`. Unlike Polling#run, this uses native OS events rather than polling.
| 21 22 23 24 25 26 27 | # File 'lib/build/files/monitor/native.rb', line 21 def run(**, &block) catch(:interrupt) do while true run_roots(self.roots, **, &block) end end end | 
#run_roots(roots, **options, &block) ⇒ Object
Monitor the specified roots for changes using native events.
| 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 | # File 'lib/build/files/monitor/native.rb', line 34 def run_roots(roots, **, &block) monitor = IO::Watch::Monitor.new(self.roots, **) monitor.run do |event| if root = event[:root] self.update([root]) yield if block_given? if self.updated return true end end end return false end |