Class: Coyote::FSListeners::Darwin
- Defined in:
- lib/coyote/fs_listeners/darwin.rb
Instance Attribute Summary collapse
-
#fsevent ⇒ Object
readonly
Returns the value of attribute fsevent.
Attributes inherited from Base
#last_event, #sha1_checksums_hash
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize ⇒ Darwin
constructor
A new instance of Darwin.
- #on_change(&callback) ⇒ Object
- #start ⇒ Object
- #stop ⇒ Object
Methods inherited from Base
#modified_files, #update_last_event
Constructor Details
#initialize ⇒ Darwin
Returns a new instance of Darwin.
5 6 7 8 |
# File 'lib/coyote/fs_listeners/darwin.rb', line 5 def initialize super @fsevent = FSEvent.new end |
Instance Attribute Details
#fsevent ⇒ Object (readonly)
Returns the value of attribute fsevent.
3 4 5 |
# File 'lib/coyote/fs_listeners/darwin.rb', line 3 def fsevent @fsevent end |
Class Method Details
.usable? ⇒ Boolean
26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/coyote/fs_listeners/darwin.rb', line 26 def self.usable? require 'rb-fsevent' if !defined?(FSEvent::VERSION) || Gem::Version.new(FSEvent::VERSION) < Gem::Version.new('0.3.9') notify "Please update rb-fsevent (>= 0.3.9)", :failure false else true end rescue LoadError notify "Please install rb-fsevent gem for Mac OSX FSEvents support", :failure false end |
Instance Method Details
#on_change(&callback) ⇒ Object
10 11 12 13 14 15 16 |
# File 'lib/coyote/fs_listeners/darwin.rb', line 10 def on_change(&callback) @fsevent.watch [Dir.pwd] do |modified_dirs| files = modified_files(modified_dirs) update_last_event callback.call(files) end end |
#start ⇒ Object
18 19 20 |
# File 'lib/coyote/fs_listeners/darwin.rb', line 18 def start @fsevent.run end |
#stop ⇒ Object
22 23 24 |
# File 'lib/coyote/fs_listeners/darwin.rb', line 22 def stop @fsevent.stop end |