#!/usr/bin/ruby # テンプレートからfml用各メールの作成 # Copyright 2007 Kenshi Muto # # テンプレート内では次のタグを利用可能 # <>: メーリングリスト名(ディレクトリ) # <>: メーリングリストの正式な名前 # <>: ファイルのインクルード require 'nkf' # 対象ML ml = [ "debian-users", "debian-devel", "debian-doc", "debian-www" ] describe = { "debian-users" => "Debian JP users", "debian-devel" => "Debian JP developers", "debian-doc" => "Debian JP documentation", "debian-www" => "Debian JP WWW" } # テンプレートファイル templates = [ "confirm", "guide", "help", "welcome" ] # 出力ディレクトリ exportdir = "../fml" # INCLUDE:の処理 def inc(file) l = "" f = File.open(file, "r") l = f.readlines f.close return l end # 各MLにテンプレート適用 ml.each {|m| templates.each {|t| out = File.open("#{exportdir}/#{m}/#{t}", "w") File.open(t, "r") {|f| f.each_line {|l| out.puts NKF.nkf("-j", l.gsub(/<]+)>>/) {|match| inc($1)}.gsub(/<>/, m).gsub(/<>/, describe[m])) } } out.close } }