Class: Listen::Adapters::Windows

Inherits:
Listen::Adapter show all
Defined in:
lib/listen/adapters/windows.rb

Overview

Adapter implementation for Windows ‘fchange`.

Constant Summary

Constants inherited from Listen::Adapter

Listen::Adapter::DEFAULT_LATENCY, Listen::Adapter::POLLING_FALLBACK_MESSAGE

Instance Attribute Summary

Attributes inherited from Listen::Adapter

#latency

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Listen::Adapter

select_and_initialize

Constructor Details

#initialize(directory, options = {}, &callback) ⇒ Windows

Initialize the Adapter. See Listen::Adapter#initialize for more info.



12
13
14
15
16
# File 'lib/listen/adapters/windows.rb', line 12

def initialize(directory, options = {}, &callback)
  super
  @changed_dirs = Set.new
  init_worker
end

Class Method Details

.usable?Boolean

Check if the adapter is usable on the current OS.

Returns:

  • (Boolean)

    whether usable or not



37
38
39
40
41
42
43
44
# File 'lib/listen/adapters/windows.rb', line 37

def self.usable?
  return false unless RbConfig::CONFIG['target_os'] =~ /mswin|mingw/i

  require 'rb-fchange'
  true
rescue LoadError
  false
end

Instance Method Details

#startObject

Start the adapter.



20
21
22
23
24
# File 'lib/listen/adapters/windows.rb', line 20

def start
  super
  Thread.new { @worker.run }
  poll_changed_dirs
end

#stopObject

Stop the adapter.



28
29
30
31
# File 'lib/listen/adapters/windows.rb', line 28

def stop
  super
  @worker.stop
end