Class: Coyote::FSListeners::Windows

Inherits:
Base
  • Object
show all
Defined in:
lib/coyote/fs_listeners/windows.rb

Instance Attribute Summary collapse

Attributes inherited from Base

#last_event, #sha1_checksums_hash

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#modified_files, #update_last_event

Constructor Details

#initializeWindows

Returns a new instance of Windows.



5
6
7
8
# File 'lib/coyote/fs_listeners/windows.rb', line 5

def initialize
  super
  @fchange = FChange::Notifier.new
end

Instance Attribute Details

#fchangeObject (readonly)

Returns the value of attribute fchange.



3
4
5
# File 'lib/coyote/fs_listeners/windows.rb', line 3

def fchange
  @fchange
end

Class Method Details

.usable?Boolean

Returns:

  • (Boolean)


27
28
29
30
31
32
33
# File 'lib/coyote/fs_listeners/windows.rb', line 27

def self.usable?
  require 'rb-fchange'
  true
rescue LoadError
  notify "Please install rb-fchange gem for Windows file events support", :failure
  false
end

Instance Method Details

#on_change(&callback) ⇒ Object



10
11
12
13
14
15
16
17
# File 'lib/coyote/fs_listeners/windows.rb', line 10

def on_change(&callback)
  @fchange.watch(Dir.pwd, :all_events, :recursive) do |event|
    paths = [File.expand_path(event.watcher.path) + '/']
    files = modified_files(paths, {:all => true})
    update_last_event
    callback.call(files)
  end
end

#startObject



19
20
21
# File 'lib/coyote/fs_listeners/windows.rb', line 19

def start
  @fchange.run
end

#stopObject



23
24
25
# File 'lib/coyote/fs_listeners/windows.rb', line 23

def stop
  @fchange.stop
end