Project

General

Profile

Bug #7958 » fileutils.patch

trans (Thomas Sawyer), 03/01/2013 05:29 PM

View differences:

lib/fileutils.rb
extend self
#
# To overcome Ruby's "Module Inclusion Problem", whenever a module
# is included into FileUtils, then the sub-modules re-include
# FileUtils to ensure inclusion of the new module as well.
#
def self.include(mod)
super mod
extend self
[Verbose, NoWrite, DryRun].each do |base|
base.send(:include, self) #FileUtils)
base.extend(base) # extend self
end
end
#
# This module has all methods of FileUtils module, but it outputs messages
# before acting. This equates to passing the <tt>:verbose</tt> flag to
# methods in FileUtils.
......
end
include StreamUtils_
extend StreamUtils_
class Entry_ #:nodoc: internal use only
include StreamUtils_
test/fileutils/test_inclusion.rb
require 'fileutils'
require 'test/unit'
class TestFileUtilsInclusion < Test::Unit::TestCase
module Foo
def foo?; true; end
end
def test_include_into_all_submodules
::FileUtils.send(:include, Foo)
assert ::FileUtils.ancestors.include?(Foo)
assert ::FileUtils::NoWrite.ancestors.include?(Foo)
assert ::FileUtils::Verbose.ancestors.include?(Foo)
assert ::FileUtils::DryRun.ancestors.include?(Foo)
assert ::FileUtils::NoWrite.foo?
assert ::FileUtils::Verbose.foo?
assert ::FileUtils::DryRun.foo?
assert ::FileUtils.foo?
end
def test_includes_streamutils
assert_include(::FileUtils::Verbose.private_instance_methods(true), :fu_stream_blksize)
end
end
(3-3/3)