Class: Staticme::Events::Emitters::FileChanged
- Inherits:
-
Object
- Object
- Staticme::Events::Emitters::FileChanged
- Defined in:
- lib/staticme/events/emitters/file_changed.rb
Instance Attribute Summary collapse
-
#_broadcast_tail ⇒ Object
Returns the value of attribute _broadcast_tail.
-
#fsevent ⇒ Object
Returns the value of attribute fsevent.
Instance Method Summary collapse
- #bind! ⇒ Object
-
#initialize ⇒ FileChanged
constructor
A new instance of FileChanged.
- #stop! ⇒ Object
Constructor Details
#initialize ⇒ FileChanged
Returns a new instance of FileChanged.
16 17 18 19 |
# File 'lib/staticme/events/emitters/file_changed.rb', line 16 def initialize self.fsevent = FSEvent.new self._broadcast_tail = Hash.new end |
Instance Attribute Details
#_broadcast_tail ⇒ Object
Returns the value of attribute _broadcast_tail.
14 15 16 |
# File 'lib/staticme/events/emitters/file_changed.rb', line 14 def _broadcast_tail @_broadcast_tail end |
#fsevent ⇒ Object
Returns the value of attribute fsevent.
13 14 15 |
# File 'lib/staticme/events/emitters/file_changed.rb', line 13 def fsevent @fsevent end |
Instance Method Details
#bind! ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/staticme/events/emitters/file_changed.rb', line 21 def bind! params = Staticme.params Staticme.on(:fs_changed) do Staticme.broadcast(:event => 'fs_change') end.on(:staticme_terminated) do self.stop! end fsevent.watch params[:path] do |dirs| signature = get_signature(dirs) next if already_broadcasted?(signature) tail_broadcast(signature) Staticme.logger.info 'FS change, publishing the event.' Staticme.emit(:fs_changed, dirs) end Thread.abort_on_exception = true Thread.new do fsevent.run end end |
#stop! ⇒ Object
47 48 49 |
# File 'lib/staticme/events/emitters/file_changed.rb', line 47 def stop! fsevent.stop end |