Class: FSSM::Backends::FSEvents
- Inherits:
-
Object
- Object
- FSSM::Backends::FSEvents
- Defined in:
- lib/fssm/backends/fsevents.rb
Instance Method Summary collapse
- #add_path(path, preload = true) ⇒ Object
-
#initialize ⇒ FSEvents
constructor
A new instance of FSEvents.
- #run ⇒ Object
Constructor Details
#initialize ⇒ FSEvents
Returns a new instance of FSEvents.
5 6 7 8 |
# File 'lib/fssm/backends/fsevents.rb', line 5 def initialize @handlers = {} @fsevents = [] end |
Instance Method Details
#add_path(path, preload = true) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/fssm/backends/fsevents.rb', line 10 def add_path(path, preload=true) handler = FSSM::State.new(path) @handlers["#{path}"] = handler fsevent = Rucola::FSEvents.new("#{path}", {:latency => 0.5}) do |events| events.each do |event| handler.refresh(event.path) end end fsevent.create_stream handler.refresh(path.to_pathname, true) if preload fsevent.start @fsevents << fsevent end |
#run ⇒ Object
26 27 28 29 30 31 32 33 34 |
# File 'lib/fssm/backends/fsevents.rb', line 26 def run begin OSX.CFRunLoopRun rescue Interrupt @fsevents.each do |fsev| fsev.stop end end end |