Safebox-dependency added and Fileparser::Base#logdb/#store added

This commit is contained in:
Denis Knauf 2010-03-29 15:51:50 +02:00
parent 3300e7dec5
commit 9706b5d991
2 changed files with 10 additions and 5 deletions

View file

@ -14,6 +14,7 @@ begin
gem.require_paths = %w[bin lib] gem.require_paths = %w[bin lib]
gem.add_dependency 'robustserver' gem.add_dependency 'robustserver'
gem.add_dependency 'sbdb' gem.add_dependency 'sbdb'
gem.add_dependency 'Safebox'
end end
Jeweler::GemcutterTasks.new Jeweler::GemcutterTasks.new
rescue LoadError rescue LoadError

View file

@ -3,13 +3,17 @@ module LogAn
module Inc module Inc
module FileParser module FileParser
module Base module Base
class <self
attr_accessor :logdb, :store
end
def emit v def emit v
@logdb.push @sid, line @@logdb.push @sid, line
end end
def seeks read def seeks read
inode, seek = (@store[ :seeks, @sid] || "\0\0\0\0\0\0\0\0").unpack 'a4N' inode, seek = (@@store[ :seeks, @sid] || "\0\0\0\0\0\0\0\0").unpack 'a4N'
@store[ :seeks, @sid] = [inode, read + seek].pack( 'a4N') @@store[ :seeks, @sid] = [inode, read + seek].pack( 'a4N')
end end
end end
@ -22,8 +26,8 @@ module LogAn
@@fileparser[sid] ||= self.new sid @@fileparser[sid] ||= self.new sid
end end
def initialize logdb, store, sid, delimiter = nil def initialize sid, delimiter = nil
@logdb, @store, @sid, @delimiter = logdb, store, sid, delimiter || "\n" @sid, @delimiter = sid, delimiter || "\n"
@delimiter = Regexp.new "^.*?#{@delimiter}" @delimiter = Regexp.new "^.*?#{@delimiter}"
@buffer, @linebuffer = Select::Buffer.new( ''), Select::Buffer.new( '') @buffer, @linebuffer = Select::Buffer.new( ''), Select::Buffer.new( '')
end end