#!/usr/bin/ruby def print_info() puts "Utility to convert text-based JIRA release notes into Confluence wiki markup" puts "" puts "Usage: #{__FILE__} [ ...]" puts " the name of the text file(s) that contain the release notes" exit end def excerpt(line) return line unless line =~ /^Release Notes/ "{excerpt}#{line.chop}{excerpt}" end def header(line) return line unless (line =~ /^\*\* /) header = line.sub(/\*\*\s/, "").chop "*#{header}*" end def link(line) line.gsub(/\[[A-Z\d]{1,7}-\d{1,4}\]/) do |match| issue = match.delete("[]") "[#{issue}|http://issues.apache.org/jira/browse/#{issue}]" end end print_info() if (ARGV.size < 1) ARGV.each do |input| output = File.basename(input, File.extname(input)) + ".wiki" puts ("Translating #{input} in #{output}") File.open(output, "w") do |out| IO.foreach(input) do |line| result = link(header(excerpt(line))) out.puts result end end end