brew/Library/Homebrew/install_renamed.rb

36 lines
618 B
Ruby
Raw Normal View History

module InstallRenamed
def install_p(_, new_basename)
super do |src, dst|
2015-03-26 22:22:45 -04:00
if src.directory?
dst
else
append_default_if_different(src, dst)
end
end
end
def cp_path_sub pattern, replacement
super do |src, dst|
append_default_if_different(src, dst)
end
end
def + path
super(path).extend(InstallRenamed)
end
def / path
super(path).extend(InstallRenamed)
end
private
2015-03-26 22:22:45 -04:00
def append_default_if_different(src, dst)
if dst.file? && !FileUtils.identical?(src, dst)
Pathname.new("#{dst}.default")
else
dst
end
end
end