Update return values of install and install_symlink

These now return an Array of all the target destinations.
Previously, if a single argument was passed a single non-
Array was returned.

This behavior has been changed so that an Array is always returned
even for a single argument.

Updated the test.

Hopefully this won't break any custom code out there.
This commit is contained in:
Adam Vandenberg 2012-02-17 23:07:16 -08:00
parent 40811ae64c
commit 847a2732ee
2 changed files with 12 additions and 7 deletions

View File

@ -3,16 +3,18 @@ require 'pathname'
# we enhance pathname to make our code more readable
class Pathname
def install *sources
results = []
sources.each do |src|
case src
when Array
src.collect {|src| install_p(src) }
src.each {|s| results << install_p(s) }
when Hash
src.collect {|src, new_basename| install_p(src, new_basename) }
src.each {|s, new_basename| results << install_p(s, new_basename) }
else
install_p(src)
results << install_p(src)
end
end
return results
end
def install_p src, new_basename = nil
@ -50,16 +52,18 @@ class Pathname
# Creates symlinks to sources in this folder.
def install_symlink *sources
results = []
sources.each do |src|
case src
when Array
src.collect {|src| install_symlink_p(src) }
src.each {|s| results << install_symlink_p(s) }
when Hash
src.collect {|src, new_basename| install_symlink_p(src, new_basename) }
src.each {|s, new_basename| results << install_symlink_p(s, new_basename) }
else
install_symlink_p(src)
results << install_symlink_p(src)
end
end
return results
end
def install_symlink_p src, new_basename = nil

View File

@ -149,7 +149,8 @@ class BeerTasting < Test::Unit::TestCase
abcd=orig_abcd=HOMEBREW_CACHE+'abcd'
FileUtils.cp ABS__FILE__, abcd
abcd=HOMEBREW_PREFIX.install abcd
installed_paths=HOMEBREW_PREFIX.install abcd
abcd = installed_paths[0]
assert (HOMEBREW_PREFIX+orig_abcd.basename).exist?
assert abcd.exist?
assert_equal HOMEBREW_PREFIX+'abcd', abcd