diff --git a/Library/Homebrew/extend/pathname.rb b/Library/Homebrew/extend/pathname.rb index fedb30ef8b..60e55278c5 100644 --- a/Library/Homebrew/extend/pathname.rb +++ b/Library/Homebrew/extend/pathname.rb @@ -8,36 +8,32 @@ class Pathname BOTTLE_EXTNAME_RX = /(\.[a-z_]+(32)?\.bottle\.(\d+\.)?tar\.gz)$/ def install *sources - results = [] sources.each do |src| case src when Array if src.empty? opoo "tried to install empty array to #{self}" - return [] + return end - src.each {|s| results << install_p(s) } + src.each {|s| install_p(s) } when Hash if src.empty? opoo "tried to install empty hash to #{self}" - return [] + return end - src.each {|s, new_basename| results << install_p(s, new_basename) } + src.each {|s, new_basename| install_p(s, new_basename) } else - results << install_p(src) + install_p(src) end end - return results end def install_p src, new_basename = nil if new_basename new_basename = File.basename(new_basename) # rationale: see Pathname.+ dst = self+new_basename - return_value = Pathname.new(dst) else dst = self - return_value = self+File.basename(src) end src = src.to_s @@ -59,25 +55,21 @@ class Pathname # this function when installing from the temporary build directory FileUtils.mv src, dst end - - return return_value end protected :install_p # Creates symlinks to sources in this folder. def install_symlink *sources - results = [] sources.each do |src| case src when Array - src.each {|s| results << install_symlink_p(s) } + src.each {|s| install_symlink_p(s) } when Hash - src.each {|s, new_basename| results << install_symlink_p(s, new_basename) } + src.each {|s, new_basename| install_symlink_p(s, new_basename) } else - results << install_symlink_p(src) + install_symlink_p(src) end end - return results end def install_symlink_p src, new_basename = nil @@ -86,14 +78,8 @@ class Pathname else dst = self+File.basename(new_basename) end - - src = src.to_s - dst = dst.to_s - mkpath - FileUtils.ln_s src, dst - - return dst + FileUtils.ln_s src.to_s, dst.to_s end protected :install_symlink_p diff --git a/Library/Homebrew/test/test_pathname.rb b/Library/Homebrew/test/test_pathname.rb index 4a9a0b0e3e..37b85a07de 100644 --- a/Library/Homebrew/test/test_pathname.rb +++ b/Library/Homebrew/test/test_pathname.rb @@ -95,14 +95,11 @@ class PathnameExtensionTests < Test::Unit::TestCase end def test_install_removes_original - orig_file = @file touch @file + @dst.install(@file) - @file, _ = @dst.install(@file) - - assert_equal orig_file.basename, @file.basename - assert @file.exist? - assert !orig_file.exist? + assert (@dst/@file.basename).exist? + assert !@file.exist? end def setup_install_test @@ -200,13 +197,6 @@ class PathnameExtensionTests < Test::Unit::TestCase end end - def test_install_returns_installed_paths - foo, bar = @src+'foo', @src+'bar' - touch [foo, bar] - dirs = @dst.install(foo, bar) - assert_equal [@dst+'foo', @dst+'bar'], dirs - end - def test_install_creates_intermediate_directories touch @file assert !@dir.directory?