brew/Library/Homebrew/install_renamed.rb
Mike McQuaid 19852bc47c Pathname: add cp_path_sub method.
This method allows copying a file to a new location by performing a
substitution on the pathname.
2013-10-10 16:46:47 +01:00

24 lines
512 B
Ruby

module InstallRenamed
def install_p src, new_basename = nil
super do |src, dst|
dst += "/#{File.basename(src)}" if File.directory? dst
append_default_if_different(src, dst)
end
end
def cp_path_sub pattern, replacement
super do |src, dst|
append_default_if_different(src, dst)
end
end
private
def append_default_if_different src, dst
if File.file? dst and !FileUtils.identical?(src, dst) and !HOMEBREW_GIT_ETC
dst += ".default"
end
dst
end
end