oocp Version 2.0.0 released.
http://raa.ruby-lang.org/list.rhtml?name=oocp
dir-compare.rb in the package is a tool kit for comparing plural
directories. For example, the recursive copy command is:
require "dir-compare"
require “ftools”
class Cp < DirPairWalker
def file_file(s, t)
File.cp(s, t)
end
def file_non(s, t)
File.cp(s, t)
end
def dir_non(s, t)
File.mkpath(t)
end
end
source, target = ARGV
visitor = Cp.new
dc = DirCompare.new(visitor)
dc.run(source, target)
And the following is the command “rm -r”:
require "dir-compare"
require “ftools”
class Rm_r < DirWalker
def file(s)
File.unlink(s)
end
def dir_out(s)
Dir.unlink(s)
end
end
rm = Rm_r.new
dc = DirCompare.new(rm)
path = ARGV.shift
dc.run(path)
The class DirCompare may assume to be an extension of Find.
Thank you.
Shin-ichiro HARA.