#!/usr/local/bin/ruby # -*- coding: utf-8 -*- require 'kconv' team = Hash.new IO.foreach("vote.tbl") do |x| x = x.toeuc sname, gname = x.scan(/([-0-9a-z]+)\s+(.*)/i)[0] next unless sname && gname team[sname] = gname end point = {} for t in team.keys point[t] = 0 end Dir.foreach(".") {|dir| next unless test(?d, dir) next if /^\./ =~ dir # dir is the same as users login name Dir.foreach(dir){|pt| next if /^\./ =~ pt file = "#{dir}/#{pt}" next unless test(?f, file) sn = open(file, "r").gets.chomp! if point.has_key?(sn) then point[sn] += pt.to_i end } } puts '' for t in point.keys.sort{|x, y| point[y] <=> point[x]} print " \n \n", team[t], t, point[t]) pt = point[t] print " \n" end puts '
" printf("%s (%3d)\n " printf '%d', pt, pt puts "
'