diff options
| author | Jack Nagel | 2015-03-26 22:22:45 -0400 | 
|---|---|---|
| committer | Jack Nagel | 2015-03-26 22:22:45 -0400 | 
| commit | 60cd70b2f235a80c53ed6d569333738e575bcf36 (patch) | |
| tree | d178c20fd356f00aa967f4ffc3c5dbd27f48bf88 | |
| parent | 05850664d6499ff3a49b180281511f1635aec935 (diff) | |
| download | homebrew-60cd70b2f235a80c53ed6d569333738e575bcf36.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 | 
