X-Git-Url: http://git.osdn.net/view?a=blobdiff_plain;f=mk_html;h=6dfd3b174304c436ccd05930ae4c7ffcffef6c45;hb=6e9f2816b581e6b6100b3df25700cd3b28ee9a7c;hp=6f32df85773ce224112a4841fa5ea1b1f891eaad;hpb=810c0751b2b94f92fd50b4c769fda4ed571f1942;p=shogi-server%2Fshogi-server.git diff --git a/mk_html b/mk_html index 6f32df8..6dfd3b1 100755 --- a/mk_html +++ b/mk_html @@ -5,7 +5,7 @@ # Homepage:: http://sourceforge.jp/projects/shogi-server/ # #-- -# Copyright (C) 2006-2008 Daigo Moriwaki +# Copyright (C) 2006-2012 Daigo Moriwaki # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -30,21 +30,31 @@ # # ./mk_html [OPTION] < players.yaml > rating.html # -# -h, --help:: +# [-h, --help] # show help # -# -w,--wdoor:: +# [-w,--wdoor] # adpot wdoor style # -# == PREREQUIRE +# [--footer filename] +# insert contents in the filename at the bottom of a genrated page. # -# * Ruby 1.8.7 and RDoc +# == Prerequire # -# $ sudo aptitude install ruby1.8 rdoc1.8 +# * Ruby 2.0.0 or later +# +# $ sudo aptitude install ruby ruby +# +# == 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' @@ -61,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 @@ -78,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 @@ -152,7 +172,7 @@ def main %> - <%= h yaml[key]['name'] %> + <%= h yaml[key]['name'] %>