diff options
author | aamine <aamine@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2004-02-16 16:23:07 +0000 |
---|---|---|
committer | aamine <aamine@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2004-02-16 16:23:07 +0000 |
commit | b1772b8c404b56bf6ac5af3b330a09a12c65c436 (patch) | |
tree | c291444977734ddb71c3c63ddc8e0e3911515f65 /lib | |
parent | dd03a2ff20bf146885066435e0cfafd3fe70d757 (diff) | |
download | ruby-b1772b8c404b56bf6ac5af3b330a09a12c65c436.tar.gz |
* lib/fileutils.rb: new module FileUtils::DryRun.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@5736 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib')
-rw-r--r-- | lib/fileutils.rb | 40 |
1 files changed, 31 insertions, 9 deletions
diff --git a/lib/fileutils.rb b/lib/fileutils.rb index 149687c44f..c8f29c3d32 100644 --- a/lib/fileutils.rb +++ b/lib/fileutils.rb @@ -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 -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 |