1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* lib/fileutils.rb: new module FileUtils::DryRun.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@5736 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
aamine 2004-02-16 16:23:07 +00:00
parent dd03a2ff20
commit b1772b8c40
2 changed files with 35 additions and 9 deletions

View file

@ -1,3 +1,7 @@
Tue Feb 17 01:20:57 2004 Minero Aoki <aamine@loveruby.net>
* lib/fileutils.rb: new module FileUtils::DryRun.
Mon Feb 16 23:28:14 2004 NAKAMURA, Hiroshi <nakahiro@sarion.co.jp>
* lib/csv.rb: document reduction. [ruby-core:02429]

View file

@ -824,12 +824,12 @@ module FileUtils
# FileUtils.
#
module Verbose
include FileUtils
@fileutils_output = $stderr
@fileutils_label = ''
@fileutils_verbose = true
@fileutils_nowrite = false
FileUtils::OPT_TABLE.each do |name, opts|
next unless opts.include?('verbose')
@ -842,38 +842,60 @@ module FileUtils
end
extend self
end
#
# This module has all methods of FileUtils module, but never changes
# files/directories. This equates to passing the <tt>:noop</tt> flag to methods in
# FileUtils.
#
module NoWrite
include FileUtils
@fileutils_output = $stderr
@fileutils_label = ''
@fileutils_verbose = false
@fileutils_nowrite = true
FileUtils::OPT_TABLE.each do |name, opts|
next unless opts.include?('noop')
module_eval(<<-EOS, __FILE__, __LINE__ + 1)
def #{name}(*args)
unless defined?(@fileutils_nowrite)
@fileutils_nowrite ||= true
end
@fileutils_nowrite = true unless defined?(@fileutils_nowrite)
super(*fu_update_option(args, :noop => true))
end
EOS
end
extend self
end
#
# This module has all methods of FileUtils module, but never changes
# files/directories, with printing message before acting.
# This equates to passing the +:noop+ and +:verbose+ flag
# to methods in FileUtils.
#
module DryRun
include FileUtils
@fileutils_output = $stderr
@fileutils_label = ''
@fileutils_verbose = true
@fileutils_nowrite = true
FileUtils::OPT_TABLE.each do |name, opts|
next unless opts.include?('noop')
module_eval(<<-EOS, __FILE__, __LINE__ + 1)
def #{name}(*args)
@fileutils_verbose = true unless defined?(@fileutils_verbose)
@fileutils_nowrite = true unless defined?(@fileutils_nowrite)
super(*fu_update_option(args, :noop => true, :verbose => true))
end
EOS
end
extend self
end
end