Deprecate Pathname#cp and Pathname#chmod_R

As far as I can tell these methods have only ever been used in the test
suite.

Since Formula includes FileUtils, it is generally simpler (and in the
case of cp, more readable) to use the FileUtils methods directly.

Closes Homebrew/homebrew#30081.
This commit is contained in:
Jack Nagel 2014-06-11 18:57:32 -05:00
parent faaa622820
commit 96195295a3
2 changed files with 2 additions and 19 deletions

View File

@ -132,6 +132,7 @@ class Pathname
private :default_stat private :default_stat
def cp dst def cp dst
opoo "Pathname#cp is deprecated, use FileUtils.cp"
if file? if file?
FileUtils.cp to_s, dst FileUtils.cp to_s, dst
else else
@ -194,6 +195,7 @@ class Pathname
end end
def chmod_R perms def chmod_R perms
opoo "Pathname#chmod_R is deprecated, use FileUtils.chmod_R"
require 'fileutils' require 'fileutils'
FileUtils.chmod_R perms, to_s FileUtils.chmod_R perms, to_s
end end

View File

@ -46,12 +46,6 @@ class PathnameExtensionTests < Test::Unit::TestCase
assert_raises(RuntimeError) { @file.write('CONTENT') } assert_raises(RuntimeError) { @file.write('CONTENT') }
end end
def test_chmod_R
perms = 0777
FileUtils.expects(:chmod_R).with(perms, @dir.to_s)
@dir.chmod_R(perms)
end
def test_atomic_write def test_atomic_write
touch @file touch @file
@file.atomic_write('CONTENT') @file.atomic_write('CONTENT')
@ -71,19 +65,6 @@ class PathnameExtensionTests < Test::Unit::TestCase
assert_equal sentinel.stat.mode, @file.stat.mode assert_equal sentinel.stat.mode, @file.stat.mode
end end
def test_cp
touch @file
mkdir_p @dir
@file.cp(@dir)
assert @file.file?
assert((@dir+@file.basename).file?)
@dir.cp(@dst)
assert @dir.directory?
assert((@dst+@dir.basename).directory?)
end
def test_ensure_writable def test_ensure_writable
touch @file touch @file
chmod 0555, @file chmod 0555, @file