Skip to content

Instantly share code, notes, and snippets.

@scottdavis
Created May 20, 2010 00:15
Show Gist options
  • Save scottdavis/407031 to your computer and use it in GitHub Desktop.
Save scottdavis/407031 to your computer and use it in GitHub Desktop.
require 'rubygems'
require 'httparty'
file = File.join("E:", "Program Files", "Sony", "EverQuest", "Logs", "eqlog_Stairs_project1999.txt")
f = File.open(file,"r")
f.seek 0 , IO::SEEK_END
def split_string_and_filter_auctions(string)
if string =~ /^\[(.+)\](.+)/
string = {:time => $1, :message => $2}
if string[:message] =~ /(.+auctions,)(.+)/
string[:message] = $2
items = parse_items(string[:message])
string[:items] = items
string.delete(:message)
items.each do |item|
HTTParty.post("http://192.168.1.21:3000/auction/create", :query => {:item => item[0], :price => item[1], :time => string[:time]})
end
return string unless items.empty?
end
end
nil
end
def parse_items(string)
regex = /([-_\'\sa-zA-Z]+)[-\s\/,]([0-9\.k]+)/
items = string.scan(regex)
items.each do|item|
item[0].gsub!(/(and|wts|wtt|wtb)/i, '')
item[0].gsub!(/[\s]+[p|-]+$/i, '')
item[0].strip!
item[0].gsub!(/^['"p|-]+[\s]+/i, '')
end
items
end
while true do
select([f])
line = f.gets
parsed = split_string_and_filter_auctions(line)
unless parsed.nil?
puts parsed.inspect
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment