mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* lib/fileutils.rb: fix visibility of FileUtils::NoWrite, Verbose, DryRun. [ruby-core:05954]
* test/fileutils/test_nowrite.rb: test it. * test/fileutils/test_dryrun.rb: new file. * test/fileutils/test_verbose.rb: new file. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@9286 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
4a092d08f4
commit
a33aa9c9f4
5 changed files with 102 additions and 8 deletions
11
ChangeLog
11
ChangeLog
|
@ -1,3 +1,14 @@
|
||||||
|
Sat Sep 24 08:29:36 2005 Minero Aoki <aamine@loveruby.net>
|
||||||
|
|
||||||
|
* lib/fileutils.rb: fix visibility of FileUtils::NoWrite, Verbose,
|
||||||
|
DryRun. [ruby-core:05954]
|
||||||
|
|
||||||
|
* test/fileutils/test_nowrite.rb: test it.
|
||||||
|
|
||||||
|
* test/fileutils/test_dryrun.rb: new file.
|
||||||
|
|
||||||
|
* test/fileutils/test_verbose.rb: new file.
|
||||||
|
|
||||||
Sat Sep 24 07:59:01 2005 Minero Aoki <aamine@loveruby.net>
|
Sat Sep 24 07:59:01 2005 Minero Aoki <aamine@loveruby.net>
|
||||||
|
|
||||||
* sample/ripper/colorize.rb: removed (replaced by ruby2html.rb).
|
* sample/ripper/colorize.rb: removed (replaced by ruby2html.rb).
|
||||||
|
|
|
@ -1080,7 +1080,7 @@ module FileUtils
|
||||||
|
|
||||||
def path
|
def path
|
||||||
if @path
|
if @path
|
||||||
@path
|
File.path(@path)
|
||||||
else
|
else
|
||||||
join(@prefix, @rel)
|
join(@prefix, @rel)
|
||||||
end
|
end
|
||||||
|
@ -1486,6 +1486,9 @@ module FileUtils
|
||||||
OPT_TABLE.keys.select {|m| OPT_TABLE[m].include?(opt.to_s) }
|
OPT_TABLE.keys.select {|m| OPT_TABLE[m].include?(opt.to_s) }
|
||||||
end
|
end
|
||||||
|
|
||||||
|
METHODS = singleton_methods() - %w( private_module_function
|
||||||
|
commands options have_option? options_of collect_method )
|
||||||
|
|
||||||
#
|
#
|
||||||
# This module has all methods of FileUtils module, but it outputs messages
|
# This module has all methods of FileUtils module, but it outputs messages
|
||||||
# before acting. This equates to passing the <tt>:verbose</tt> flag to
|
# before acting. This equates to passing the <tt>:verbose</tt> flag to
|
||||||
|
@ -1500,9 +1503,15 @@ module FileUtils
|
||||||
def #{name}(*args)
|
def #{name}(*args)
|
||||||
super(*fu_update_option(args, :verbose => true))
|
super(*fu_update_option(args, :verbose => true))
|
||||||
end
|
end
|
||||||
|
private :#{name}
|
||||||
EOS
|
EOS
|
||||||
end
|
end
|
||||||
extend self
|
extend self
|
||||||
|
class << self
|
||||||
|
::FileUtils::METHODS.each do |m|
|
||||||
|
public m
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
#
|
#
|
||||||
|
@ -1519,9 +1528,15 @@ module FileUtils
|
||||||
def #{name}(*args)
|
def #{name}(*args)
|
||||||
super(*fu_update_option(args, :noop => true))
|
super(*fu_update_option(args, :noop => true))
|
||||||
end
|
end
|
||||||
|
private :#{name}
|
||||||
EOS
|
EOS
|
||||||
end
|
end
|
||||||
extend self
|
extend self
|
||||||
|
class << self
|
||||||
|
::FileUtils::METHODS.each do |m|
|
||||||
|
public m
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
#
|
#
|
||||||
|
@ -1539,9 +1554,15 @@ module FileUtils
|
||||||
def #{name}(*args)
|
def #{name}(*args)
|
||||||
super(*fu_update_option(args, :noop => true, :verbose => true))
|
super(*fu_update_option(args, :noop => true, :verbose => true))
|
||||||
end
|
end
|
||||||
|
private :#{name}
|
||||||
EOS
|
EOS
|
||||||
end
|
end
|
||||||
extend self
|
extend self
|
||||||
|
class << self
|
||||||
|
::FileUtils::METHODS.each do |m|
|
||||||
|
public m
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
25
test/fileutils/test_dryrun.rb
Normal file
25
test/fileutils/test_dryrun.rb
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
# $Id$
|
||||||
|
|
||||||
|
require 'test/unit'
|
||||||
|
require 'fileutils'
|
||||||
|
|
||||||
|
class TestFileUtilsDryRun < Test::Unit::TestCase
|
||||||
|
|
||||||
|
include FileUtils::DryRun
|
||||||
|
|
||||||
|
def test_visibility
|
||||||
|
FileUtils::METHODS.each do |m|
|
||||||
|
assert_equal true, FileUtils::DryRun.respond_to?(m, true),
|
||||||
|
"FileUtils::DryRun.#{m} not defined"
|
||||||
|
assert_equal true, FileUtils::DryRun.respond_to?(m, false),
|
||||||
|
"FileUtils::DryRun.#{m} not public"
|
||||||
|
end
|
||||||
|
FileUtils::METHODS.each do |m|
|
||||||
|
assert_equal true, respond_to?(m, true)
|
||||||
|
"FileUtils::DryRun\##{m} is not defined"
|
||||||
|
assert_equal true, FileUtils::DryRun.private_method_defined?(m),
|
||||||
|
"FileUtils::DryRun\##{m} is not private"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
|
@ -1,18 +1,30 @@
|
||||||
#
|
# $Id$
|
||||||
# test/fileutils/test_nowrite.rb
|
|
||||||
#
|
|
||||||
|
|
||||||
require 'fileutils'
|
require 'fileutils'
|
||||||
require 'fileasserts'
|
require 'fileasserts'
|
||||||
require 'tmpdir'
|
require 'tmpdir'
|
||||||
require 'test/unit'
|
require 'test/unit'
|
||||||
|
|
||||||
|
class TestFileUtilsNoWrite < Test::Unit::TestCase
|
||||||
class TestNoWrite < Test::Unit::TestCase
|
|
||||||
|
|
||||||
include FileUtils::NoWrite
|
include FileUtils::NoWrite
|
||||||
|
|
||||||
def my_rm_rf( path )
|
def test_visibility
|
||||||
|
FileUtils::METHODS.each do |m|
|
||||||
|
assert_equal true, FileUtils::NoWrite.respond_to?(m, true),
|
||||||
|
"FileUtils::NoWrite.#{m} is not defined"
|
||||||
|
assert_equal true, FileUtils::NoWrite.respond_to?(m, false),
|
||||||
|
"FileUtils::NoWrite.#{m} is not public"
|
||||||
|
end
|
||||||
|
FileUtils::METHODS.each do |m|
|
||||||
|
assert_equal true, respond_to?(m, true),
|
||||||
|
"FileUtils::NoWrite\##{m} is not defined"
|
||||||
|
assert_equal true, FileUtils::NoWrite.private_method_defined?(m),
|
||||||
|
"FileUtils::NoWrite\##{m} is not private"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def my_rm_rf(path)
|
||||||
if File.exist?('/bin/rm')
|
if File.exist?('/bin/rm')
|
||||||
system %Q[/bin/rm -rf "#{path}"]
|
system %Q[/bin/rm -rf "#{path}"]
|
||||||
else
|
else
|
||||||
|
@ -50,7 +62,7 @@ class TestNoWrite < Test::Unit::TestCase
|
||||||
check 'tmp/mv'
|
check 'tmp/mv'
|
||||||
end
|
end
|
||||||
|
|
||||||
def check( dest )
|
def check(dest)
|
||||||
assert_file_not_exist dest
|
assert_file_not_exist dest
|
||||||
assert_file_exist SRC
|
assert_file_exist SRC
|
||||||
assert_same_file SRC, COPY
|
assert_same_file SRC, COPY
|
||||||
|
|
25
test/fileutils/test_verbose.rb
Normal file
25
test/fileutils/test_verbose.rb
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
# $Id$
|
||||||
|
|
||||||
|
require 'test/unit'
|
||||||
|
require 'fileutils'
|
||||||
|
|
||||||
|
class TestFileUtilsVerbose < Test::Unit::TestCase
|
||||||
|
|
||||||
|
include FileUtils::Verbose
|
||||||
|
|
||||||
|
def test_visibility
|
||||||
|
FileUtils::METHODS.each do |m|
|
||||||
|
assert_equal true, FileUtils::Verbose.respond_to?(m, true),
|
||||||
|
"FileUtils::Verbose.#{m} is not defined"
|
||||||
|
assert_equal true, FileUtils::Verbose.respond_to?(m, false),
|
||||||
|
"FileUtils::Verbose.#{m} is not public"
|
||||||
|
end
|
||||||
|
FileUtils::METHODS.each do |m|
|
||||||
|
assert_equal true, respond_to?(m, true),
|
||||||
|
"FileUtils::Verbose.#{m} is not defined"
|
||||||
|
assert_equal true, FileUtils::Verbose.private_method_defined?(m),
|
||||||
|
"FileUtils::Verbose.#{m} is not private"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
Loading…
Reference in a new issue