class Carnivore::Files::Util::Fetcher::Poll
Polling fetcher
Public Instance Methods
destroy_io()
click to toggle source
Destroy the IO instance and monitor
@return [TrueClass]
# File lib/carnivore-files/util/poll.rb, line 36 def destroy_io if(io) io.close @io = nil end true end
start_fetcher()
click to toggle source
Start the fetcher
# File lib/carnivore-files/util/poll.rb, line 12 def start_fetcher loop do build_io ino = io.stat.ino retrieve_lines.each do |line| self.messages << line end pos = io.pos sleep(1) begin if(io.size < pos || ino != File.stat(path).ino) destroy_io @waited = true end rescue Errno::ENOENT destroy_io @waited = true end end end
wait_for_file()
click to toggle source
Wait helper for file to appear (2 second intervals)
@return [TrueClass]
# File lib/carnivore-files/util/poll.rb, line 47 def wait_for_file warn "Waiting for file to appear (#{path})" until(::File.exists?(path)) @waited = true sleep(2) end info "File has appeared (#{path})!" end