X-Git-Url: http://git.sourceforge.jp/view?a=blobdiff_plain;f=mk_html;h=956be0a2f33c028d8ced2f6a578ad8d1c9d64d1c;hb=ce2ee8b7d6eda3c8dacafd4139b4e4dc309708b1;hp=7bf22db2c9005db231d48e86c012585bbe5743cb;hpb=e6d943c00f255acf62c00f5f4d5b3354b34567e2;p=shogi-server%2Fshogi-server.git diff --git a/mk_html b/mk_html index 7bf22db..956be0a 100755 --- a/mk_html +++ b/mk_html @@ -1,8 +1,10 @@ #!/usr/bin/ruby # $Id$ # -# = Copyright +# Author:: Daigo Moriwaki +# Homepage:: http://sourceforge.jp/projects/shogi-server/ # +#-- # Copyright (C) 2006-2008 Daigo Moriwaki # # This program is free software; you can redistribute it and/or modify @@ -18,24 +20,41 @@ # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +#++ # -# = Synopsis +# == Synopsis # -# mk_html generates an html page from players.yaml. +# mk_html generates an html page from a players.yaml. # -# = Usage +# == Usage # -# ./mk_html [OPTION] < players.yaml > rating.html +# ./mk_html [OPTION] < players.yaml > rating.html # -# -h, --help:: +# [-h, --help] # show help # -# -w,--wdoor:: +# [-w,--wdoor] # adpot wdoor style # +# [--footer filename] +# insert contents in the filename at the bottom of a genrated page. +# +# == Prerequire +# +# * Ruby 1.8.7 +# +# $ sudo aptitude install ruby ruby1.8 +# +# == Example +# +# $ ./mk_html --footer ./wdoor_1000.html < players.yaml > players.html +# +# $ cat ./wdoor-1000.html +#

The average of the rates in a group is always 1000. +#

BACK +# require 'optparse' -require 'rdoc/usage' require 'yaml' require 'erb' @@ -52,13 +71,6 @@ def show_date(time) end end -def usage - $stderr.puts <<-EOF -USAGE: #{$0} - EOF - exit 1 -end - def remove_long_to_see_players(file) return unless file["players"][999] # only for Not-Yet-Rated players @@ -69,10 +81,27 @@ end def main $wdoor = false + $footer_content = nil opts = OptionParser.new - opts.on("-h", "--help"){ RDoc::usage(0, 'Synopsis', 'Usage') } - opts.on("-w","--wdoor") { $wdoor=true } - opts.parse(ARGV) rescue RDoc::usage(1, 'Synopsis', 'Usage') + opts.banner = "Usage: mk_html [OPTIONS]" + opts.on("--footer filename", String, "Insert contents of the filename at the bottom of a genrated page") do |filename| + unless File.exist?(filename) + $stderr.puts "File not found: %s" % [filename] + raise + end + $footer_content = File.open(filename).read + end + opts.on("-w","--wdoor", "adopt a wdoor style") { $wdoor=true } + opts.on_tail("-h", "--help", "show this message") do + puts opts + exit + end + begin + opts.parse(ARGV) + rescue + puts opts + exit -1 + end lines = "" while l = $stdin.gets do @@ -264,8 +293,8 @@ __END__ % end

Groups are independently rated. You can not compare rates across them. -

The average of the rates in a group is always 1000. -

BACK + +<%= $footer_content %>