diff options
| author | Jack Nagel | 2015-03-26 22:22:45 -0400 |
|---|---|---|
| committer | Jack Nagel | 2015-03-26 22:22:45 -0400 |
| commit | 96f7a8015f0b8ffd0fdd6b72dfea0ffe5c2ad389 (patch) | |
| tree | ee294e9dc97d7624b0a8e7f76b452580d3639106 | |
| parent | 3721e0be6fc058e66603d46ba4565c5d84f0666b (diff) | |
| download | brew-96f7a8015f0b8ffd0fdd6b72dfea0ffe5c2ad389.tar.bz2 | |
Pass around only pathname objects
| -rw-r--r-- | Library/Homebrew/extend/pathname.rb | 7 | ||||
| -rw-r--r-- | Library/Homebrew/install_renamed.rb | 11 |
2 files changed, 9 insertions, 9 deletions
diff --git a/Library/Homebrew/extend/pathname.rb b/Library/Homebrew/extend/pathname.rb index 7ab3cad54..f812e2076 100644 --- a/Library/Homebrew/extend/pathname.rb +++ b/Library/Homebrew/extend/pathname.rb @@ -37,9 +37,8 @@ class Pathname def install_p(src, new_basename) raise Errno::ENOENT, src.to_s unless File.symlink?(src) || File.exist?(src) - src = src.to_s - dst = join(new_basename).to_s - + src = Pathname(src) + dst = join(new_basename) dst = yield(src, dst) if block_given? mkpath @@ -48,7 +47,7 @@ class Pathname # is a symlink, and its target is moved first, FileUtils.mv will fail: # https://bugs.ruby-lang.org/issues/7707 # In that case, use the system "mv" command. - if File.symlink? src + if src.symlink? raise unless Kernel.system 'mv', src, dst else FileUtils.mv src, dst diff --git a/Library/Homebrew/install_renamed.rb b/Library/Homebrew/install_renamed.rb index 23d88d1ba..98ddd05c8 100644 --- a/Library/Homebrew/install_renamed.rb +++ b/Library/Homebrew/install_renamed.rb @@ -1,7 +1,7 @@ module InstallRenamed def install_p(_, new_basename) super do |src, dst| - if File.directory?(src) + if src.directory? dst else append_default_if_different(src, dst) @@ -25,10 +25,11 @@ module InstallRenamed private - def append_default_if_different src, dst - if File.file? dst and !FileUtils.identical?(src, dst) - dst += ".default" + def append_default_if_different(src, dst) + if dst.file? && !FileUtils.identical?(src, dst) + Pathname.new("#{dst}.default") + else + dst end - dst end end |
