#! /usr/bin/env ruby

require "ftools"
require "rd/package"

ARGV.each do |filename|
  File.cp(filename, filename + ".bak")
  oldfile = File.open(filename + ".bak")
  newfile = File.open(filename, "w")
  oldfile.each do |line|
    new_line = line.gsub(/\$Version.*\$/, "$Version: #{RD::PACKAGE_VERSION}$") #"
    newfile.print new_line
  end
  STDERR.puts "updated #{filename}."
end
