New eventmachine-tail features
Posted Tue, 25 May 2010
I added block support to EM::file_tail in the eventmachine-tail gem. This lets
you give a handler to the tail instead of a class, which could mean less code
to write for the common case (handle lines of input):
require "rubygems"
require "eventmachine-tail"
def main(args)
if args.length == 0
puts "Usage: #{$0} <path> [path2] [...]"
return 1
end
EventMachine.run do
args.each do |path|
EventMachine::file_tail(path) do |filetail, line|
# filetail is the 'EventMachine::FileTail' instance for this file.
# line is the line read from thefile.
# this block is invoked for every line read.
puts line
end
end
end # EventMachine.run
end # def main
exit(main(ARGV))
You can use gem to install the latest eventmachine-tail.
You can also pull the latest from github