2015-04-26 09:42:23 -04:00
|
|
|
require './environments'
|
2015-04-25 13:17:47 -04:00
|
|
|
|
|
|
|
def rebuild_leaders
|
|
|
|
puts "rebuilding_leaders called"
|
|
|
|
Leader.destroy_all
|
|
|
|
|
|
|
|
mechanize = Mechanize.new
|
|
|
|
page = mechanize.get('http://trugul.com/highscores')
|
|
|
|
leaders = page.search "//table[@id='highscores_table']//tr[@class='clickable']/td[2]"
|
|
|
|
|
|
|
|
leaders.each do |td_user|
|
|
|
|
user = td_user.text.scan(/[A-Za-z0-9]+/).first
|
|
|
|
|
|
|
|
Leader.new(leader: user).save
|
|
|
|
end
|
|
|
|
end
|