class Tailer::StackTail

Extends FileTail to push data tailed to an EM::Channel. All open websockets subscribe to a channel for the request stack and this pushes the data to all of them at once.

Public Class Methods

new(filename, channel, startpos=-1) click to toggle source
Calls superclass method
# File lib/deployinator/stack-tail.rb, line 9
def initialize(filename, channel, startpos=-1)
  super(filename, startpos)
  @channel = channel
  @buffer = BufferedTokenizer.new
end

Public Instance Methods

receive_data(data) click to toggle source

This method is called whenever FileTail receives and inotify event for the tailed file. It breaks up the data per line and pushes a line at a time. This is to prevent the last javascript line from being broken up over 2 pushes thus breaking the eval on the front end.

# File lib/deployinator/stack-tail.rb, line 19
def receive_data(data)
  @buffer.extract(data).each do |line|
    @channel.push line
  end
end