format_svn_log.rbの修正
RubyにはHashがあるのでアクセサだけのクラスをわざわざ作るのは無駄でした。
なので、修正しました。
#!/usr/bin/ruby #format_svn_log.rb require "rexml/document" require "time.rb" require 'erb' class LogEntries < Array def initialize(log) begin doc = REXML::Document.new(log) doc.elements.each("log/logentry") do |elem| ent = Hash.new ent[:revision] = elem.attributes["revision"] ent[:author] = elem.elements["author"].text ent[:date] = Time.xmlschema(elem.elements["date"].text) ent[:msg] = elem.elements["msg"].text ent[:paths] = Array.new elem.elements["paths"].elements.each("path") do |child| path = Hash.new path[:action] = child.attributes["action"] path[:path] = child.text ent[:paths].push(path) end self.push(ent) end rescue raise "Bad log file!\n#{$!}" end end end class Printer SCRIPT = <<EOS <font size="2"> <% entries.each do |ent| %> ------------------------------------------------------------------------ <span style="background-color: rgb(192, 192, 192); font-weight: bold;"> r<%= ent[:revision] %> | <%= ent[:author] %> | <%= ent[:date].getlocal %> | </span> 変更のあったパス: <% ent[:paths].each do |path| %> <%= path[:action] %> <%= path[:path] %> <% end %> <%= ent[:msg] %> <% end %> </font> EOS def initialize() @erb = ERB.new(SCRIPT) end def print(entries) @erb.result(binding) end end if ARGV[0] log = File.open(ARGV[0]) else log = STDIN end begin entries = LogEntries.new(log) rescue warn "Bad log file!" exit 1 end puts Printer.new().print(entries)