Class: Coyote::FSListeners::Windows
- Defined in:
- lib/coyote/fs_listeners/windows.rb
Instance Attribute Summary collapse
-
#fchange ⇒ Object
readonly
Returns the value of attribute fchange.
Attributes inherited from Base
#last_event, #sha1_checksums_hash
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize ⇒ Windows
constructor
A new instance of Windows.
- #on_change(&callback) ⇒ Object
- #start ⇒ Object
- #stop ⇒ Object
Methods inherited from Base
#modified_files, #update_last_event
Constructor Details
#initialize ⇒ Windows
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
#fchange ⇒ Object (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
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.(event.watcher.path) + '/'] files = modified_files(paths, {:all => true}) update_last_event callback.call(files) end end |
#start ⇒ Object
19 20 21 |
# File 'lib/coyote/fs_listeners/windows.rb', line 19 def start @fchange.run end |
#stop ⇒ Object
23 24 25 |
# File 'lib/coyote/fs_listeners/windows.rb', line 23 def stop @fchange.stop end |