Sha256: 1a977512171896e44016d04289d9f81e745ba3ebec603a978a3fdeaf16e754ea

Contents?: true

Size: 1.39 KB

Versions: 6

Compression:

Stored size: 1.39 KB

Contents

#!/usr/bin/env ruby

require 'pathname'

class String
  def uttk_rename!
    r = gsub!(/([^Uu])ttk/, '\1uttk') || r
    r = gsub!(/^ttk/, 'uttk') || r
    r = gsub!(/([^uU])ttk/, '\1Uttk') || r
    r = gsub!(/^T[Tt][Kk]/, 'Uttk') || r
    r = gsub!(/([^Uu])T[tT][kK]/, '\1Uttk') || r
    r = gsub!(/TestTKewl/, 'Unified Test Tool Kit') || r
    r = gsub!(/TestToolKit/, 'Unified Test Tool Kit') || r
    # r = gsub!(/([^Uu ][^Nn ][^Ii ][^Ff ][^Ii ][^Ee ][^Dd ]\s*)(\s*?[tT][Ee][Ss][Tt]\s*[Tt][Oo][Oo][Ll]\s*[Kk][Ii][Tt])/, '\1 Unified\2') || r
    (r)? self : nil
  end
end

class Pathname
  def uttk_rename!
    path = self
    if new = basename.to_s.uttk_rename!
      p = dirname + new
      if system("svn move #{self} #{p} --force")
        path = p
      end
      r = self
    end
    unless path.directory?
      r = path.read.uttk_rename!
      if r
        path.open('w') { |f| f.syswrite(r) }
      end
    end
    (r)? self : nil
  end
end

ARGV.each do |arg|
  Pathname.new(arg).find do |path|
    next if path.to_s == /^\.\.?$/
    Find.prune if path.to_s =~ /\.svn/
    next unless path.directory?
    if path.uttk_rename!
      STDERR.puts "- #{path}"
    end
  end
  Pathname.new(arg).find do |path|
    next if path.to_s == /renaming/
    next if path.to_s == /^\.\.?$/
    Find.prune if path.to_s =~ /\.svn/
    next if path.directory?
    if path.uttk_rename!
      STDERR.puts "- #{path}"
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
uttk-0.3.1.2 misc/renaming
uttk-0.3.6.1 misc/renaming
uttk-0.3.5.0 misc/renaming
uttk-0.4.6.2 misc/renaming
uttk-0.4.6.1 misc/renaming
uttk-0.4.5.0 misc/renaming