Sha256: 4a2f8b8c0fbcfb8ff2209a605cd5d98ad136c778c4c49b56657f5e9ac31eb868

Contents?: true

Size: 685 Bytes

Versions: 1

Compression:

Stored size: 685 Bytes

Contents

require 'filewatch/tail'
require 'addressable/uri'
require 'yajl'
require 'socket'
require 'time'
require 'thread'
require 'forwardable'

class Woodchuck::Watcher
  extend Forwardable
  
  attr_accessor :tailer, :paths, :logger, :events, :agent
  def_delegator :@agent, :output, :output
  
  def initialize(agent, *paths)
    @agent = agent
    @logger = Woodchuck::Logger.new(::STDOUT)
    @tailer = FileWatch::Tail.new
    @paths = paths.flatten
  end

  def start
    paths.each do |path|
      tailer.tail(path)
    end
    tailer.subscribe do |path, line|
      event = Woodchuck::Event.new(path, line)
      output.handle(event)
    end
  end
  
  def inspect
    to_s
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
woodchuck-0.0.1 lib/woodchuck/watcher.rb