Sha256: 84163db591189266ece1f2c211a5441d25ed3159bfeac8a491c69e33f6a24144

Contents?: true

Size: 840 Bytes

Versions: 2

Compression:

Stored size: 840 Bytes

Contents

require "eventmachine"
require "eventmachine-tail"
require 'addressable/uri'
require 'yajl'
require 'socket'
require 'time'
require 'thread'
require 'forwardable'
require 'woodchuck/tail_reader'

class Woodchuck::Watcher
  extend Forwardable
  
  attr_accessor :paths, :logger, :events, :agent, :input_format
  def_delegator :@agent, :output, :output
  
  def initialize(agent, log_level, input_format, *paths)
    @agent = agent
    @logger = Woodchuck::Logger.new(::STDOUT)
		@logger.level = log_level unless log_level.nil?
    @paths = paths.flatten.compact
		@input_format = input_format
  end

  def start
		Woodchuck::TailReader.static_init(input_format, output)

		EventMachine.run do
			paths.each do |path|
				EventMachine::FileGlobWatchTail.new(path, Woodchuck::TailReader)
			end
		end
  end
  
  def inspect
    to_s
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
woodchuck-json-event-0.0.2 lib/woodchuck/watcher.rb
woodchuck-json-event-0.0.1 lib/woodchuck/watcher.rb