Class: Carnivore::Files::Util::Fetcher::Penguin
- Inherits:
-
Carnivore::Files::Util::Fetcher
- Object
- Carnivore::Files::Util::Fetcher
- Carnivore::Files::Util::Fetcher::Penguin
- Defined in:
- lib/carnivore-files/util/penguin.rb
Overview
NIO based fetcher
Instance Attribute Summary collapse
- #notify ⇒ SP::Inotify
-
#notify_descriptors ⇒ Hash
Registered file descriptors.
Attributes inherited from Carnivore::Files::Util::Fetcher
#delimiter, #io, #messages, #path
Instance Method Summary collapse
-
#initialize(args = {}) ⇒ Penguin
constructor
Create new instance.
-
#start_fetcher ⇒ Object
Start the fetcher.
Methods inherited from Carnivore::Files::Util::Fetcher
Constructor Details
#initialize(args = {}) ⇒ Penguin
Create new instance
19 20 21 22 23 |
# File 'lib/carnivore-files/util/penguin.rb', line 19 def initialize(args={}) super @notify = SP::Inotify.new @notify_descriptors = {} end |
Instance Attribute Details
#notify ⇒ SP::Inotify
12 13 14 |
# File 'lib/carnivore-files/util/penguin.rb', line 12 def notify @notify end |
#notify_descriptors ⇒ Hash
Returns registered file descriptors.
14 15 16 |
# File 'lib/carnivore-files/util/penguin.rb', line 14 def notify_descriptors @notify_descriptors end |
Instance Method Details
#start_fetcher ⇒ Object
Start the fetcher
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/carnivore-files/util/penguin.rb', line 26 def start_fetcher loop do build_io notify.each do |event| Celluloid::Future.new{ event.events }.value.each do |ev| case ev when :MODIFY retrieve_lines.each do |l| self. << l end when :MOVE_SELF, :DELETE_SELF, :ATTRIB info "Destroying file IO due to FS modification! (#{ev.inspect})" destroy_io @waited = true break else debug "Received unhandled event: #{ev.inspect}" end end break unless io end end end |