Sha256: e7d7456a40b4c04c386960b76fe3c3b0db0421e1c85021e08cbf96715498e158

Contents?: true

Size: 986 Bytes

Versions: 5

Compression:

Stored size: 986 Bytes

Contents

#!/usr/bin/env ruby
require 'find'
require 'fileutils'
rfdir = 'rubyforge.org:/var/www/gforge-projects/clogger/'
newbase = 'http://clogger.bogomips.org/'
refresh = '<meta http-equiv="refresh" content="0; url=%s" />'
old = 'rf.old'
new = 'rf.new'
cmd = %W(rsync -av #{rfdir} #{old}/)
unless File.directory?(old)
  system(*cmd) or abort "#{cmd.inspect} failed: #$?"
end

Find.find(old) do |path|
  path =~ /\.html\z/ or next
  data = File.read(path)
  tmp = path.split(%r{/})
  tmp.shift == old or abort "BUG"
  dst = "#{new}/#{tmp.join('/')}"

  tmp[-1] = '' if tmp[-1] == "index.html"
  url = "#{newbase}#{tmp.join('/')}"
  meta = sprintf(refresh, url)
  data.sub!(/(<head[^>]*>)/i, "#$1#{meta}")
  data.sub!(/(<body[^>]*>)/i,
            "#{$1}Redirecting to <a href=\"#{url}\">#{url}</a> ...<br/>")
  FileUtils.mkdir_p(File.dirname(dst))
  File.open(dst, "w") { |fp| fp.write(data) }
end

print "Verify results in #{new}/, then run:\n  "
puts %W(rsync -av #{new}/ #{rfdir}).join(' ')

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
clogger-2.2.0 archive/rfmig.rb
clogger-2.1.0 archive/rfmig.rb
clogger-2.0.2 archive/rfmig.rb
clogger-2.0.1 archive/rfmig.rb
clogger-2.0.0 archive/rfmig.rb