aboutsummaryrefslogtreecommitdiffstats
path: root/Library/Homebrew
diff options
context:
space:
mode:
authorJack Nagel2015-03-23 21:03:55 -0400
committerJack Nagel2015-03-24 21:03:45 -0400
commit6f0efd6f3dcb810f5f14770effd52ea07e1fdffe (patch)
treead2ecd33095b3ec2a58e63dfc66805bade7ca0f6 /Library/Homebrew
parent453990f1aa7435c79b5a2af4acf043b93149bf19 (diff)
downloadbrew-6f0efd6f3dcb810f5f14770effd52ea07e1fdffe.tar.bz2
Always pass basename to install_p
Currently, when called with one argument, dst is set to self, i.e. the directory into which the source file should be moved. When called with a second argument (for renames), dst is the full path, including the basename, to the moved file. Instead, let's always pass the full path, which means we can remove the branching logic around computing dst.
Diffstat (limited to 'Library/Homebrew')
-rw-r--r--Library/Homebrew/extend/pathname.rb15
-rw-r--r--Library/Homebrew/install_renamed.rb4
2 files changed, 6 insertions, 13 deletions
diff --git a/Library/Homebrew/extend/pathname.rb b/Library/Homebrew/extend/pathname.rb
index 6f9f4d069..17b11eb87 100644
--- a/Library/Homebrew/extend/pathname.rb
+++ b/Library/Homebrew/extend/pathname.rb
@@ -21,28 +21,23 @@ class Pathname
opoo "tried to install empty array to #{self}"
return
end
- src.each {|s| install_p(s) }
+ src.each { |s| install_p(s, File.basename(s)) }
when Hash
if src.empty?
opoo "tried to install empty hash to #{self}"
return
end
- src.each {|s, new_basename| install_p(s, new_basename) }
+ src.each { |s, new_basename| install_p(s, new_basename) }
else
- install_p(src)
+ install_p(src, File.basename(src))
end
end
end
- def install_p src, new_basename = nil
+ def install_p(src, new_basename)
raise Errno::ENOENT, src.to_s unless File.symlink?(src) || File.exist?(src)
- if new_basename
- new_basename = File.basename(new_basename) # rationale: see Pathname.+
- dst = self+new_basename
- else
- dst = self
- end
+ dst = join(new_basename)
src = src.to_s
dst = dst.to_s
diff --git a/Library/Homebrew/install_renamed.rb b/Library/Homebrew/install_renamed.rb
index e88ecb8c5..f72fe1309 100644
--- a/Library/Homebrew/install_renamed.rb
+++ b/Library/Homebrew/install_renamed.rb
@@ -1,8 +1,6 @@
module InstallRenamed
- def install_p _, new_basename = nil
+ def install_p(_, new_basename)
super do |src, dst|
- dst += "/#{File.basename(src)}" if File.directory? dst
-
if File.directory? src
Pathname.new(dst).install Dir["#{src}/*"]
next