# File class/main.rb, line 37 def run @listfile.each {|file| tag = Tag.new(file) html = open(file) {|fp| fp.read} puts "#{file}を処理します。" asitag = / ( # $1:開始タグ <!-- \s* ASI \s+ (.*?) \s* --> # $2:コマンド ) (.*?) # $3:挿入文字列 (<!-- \s* \/ASI \s* -->) # $4:終了タグ /imx html.gsub!(asitag){ $1 + tag.write($2, $3) + $4 } if tag.changed? open(file, 'w'){|fp| fp.print html } puts "#{file}を更新しました。" end } end