diff options
| author | Jack Nagel | 2015-03-23 21:03:55 -0400 | 
|---|---|---|
| committer | Jack Nagel | 2015-03-24 21:03:45 -0400 | 
| commit | c2b8017e68068eca9589aa6020da800f0e668264 (patch) | |
| tree | 023d2fc15ab30fa1f25735a0e486cb92548faee6 /Library/Homebrew/extend/pathname.rb | |
| parent | 0bc8c8c299a9130042d802b55ea932266aedc5fd (diff) | |
| download | homebrew-c2b8017e68068eca9589aa6020da800f0e668264.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/extend/pathname.rb')
| -rw-r--r-- | Library/Homebrew/extend/pathname.rb | 15 | 
1 files changed, 5 insertions, 10 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  | 
