Rename Keg#fname to Keg#name

This commit is contained in:
Jack Nagel 2014-06-24 19:04:52 -05:00
parent def6b1eaf7
commit 3d69e5ab7b
4 changed files with 17 additions and 19 deletions

View File

@ -12,10 +12,10 @@ module Homebrew
ARGV.kegs.each do |keg| ARGV.kegs.each do |keg|
if keg.linked? if keg.linked?
opoo "Already linked: #{keg}" opoo "Already linked: #{keg}"
puts "To relink: brew unlink #{keg.fname} && brew link #{keg.fname}" puts "To relink: brew unlink #{keg.name} && brew link #{keg.name}"
next next
elsif keg_only?(keg.fname) && !ARGV.force? elsif keg_only?(keg.name) && !ARGV.force?
opoo "#{keg.fname} is keg-only and must be linked with --force" opoo "#{keg.name} is keg-only and must be linked with --force"
puts "Note that doing so can interfere with building software." puts "Note that doing so can interfere with building software."
next next
elsif mode.dry_run && mode.overwrite elsif mode.dry_run && mode.overwrite

View File

@ -11,7 +11,7 @@ module Homebrew
puts "Uninstalling #{keg}..." puts "Uninstalling #{keg}..."
keg.unlink keg.unlink
keg.uninstall keg.uninstall
rm_pin keg.fname rm_pin keg.name
end end
end end
else else

View File

@ -7,7 +7,7 @@ class Keg < Pathname
class AlreadyLinkedError < RuntimeError class AlreadyLinkedError < RuntimeError
def initialize(keg) def initialize(keg)
super <<-EOS.undent super <<-EOS.undent
Cannot link #{keg.fname} Cannot link #{keg.name}
Another version is already linked: #{keg.linked_keg_record.resolved_path} Another version is already linked: #{keg.linked_keg_record.resolved_path}
EOS EOS
end end
@ -30,8 +30,8 @@ class Keg < Pathname
"already exists. You may want to remove it:\n rm #{dst}\n" "already exists. You may want to remove it:\n rm #{dst}\n"
else else
<<-EOS.undent <<-EOS.undent
is a symlink belonging to #{conflict.fname}. You can unlink it: is a symlink belonging to #{conflict.name}. You can unlink it:
brew unlink #{conflict.fname} brew unlink #{conflict.name}
EOS EOS
end end
@ -41,10 +41,10 @@ class Keg < Pathname
s << "Target #{dst}" << suggestion s << "Target #{dst}" << suggestion
s << <<-EOS.undent s << <<-EOS.undent
To force the link and overwrite all conflicting files: To force the link and overwrite all conflicting files:
brew link --overwrite #{keg.fname} brew link --overwrite #{keg.name}
To list all files that would be deleted: To list all files that would be deleted:
brew link --overwrite --dry-run #{keg.fname} brew link --overwrite --dry-run #{keg.name}
EOS EOS
s.join("\n") s.join("\n")
end end
@ -88,20 +88,22 @@ class Keg < Pathname
raise NotAKegError, "#{path} is not inside a keg" raise NotAKegError, "#{path} is not inside a keg"
end end
attr_reader :linked_keg_record attr_reader :name, :linked_keg_record
alias_method :fname, :name
def initialize path def initialize path
super path super path
raise "#{to_s} is not a valid keg" unless parent.parent.realpath == HOMEBREW_CELLAR.realpath raise "#{to_s} is not a valid keg" unless parent.parent.realpath == HOMEBREW_CELLAR.realpath
raise "#{to_s} is not a directory" unless directory? raise "#{to_s} is not a directory" unless directory?
@linked_keg_record = HOMEBREW_LIBRARY.join("LinkedKegs", fname) @name = parent.basename.to_s
@linked_keg_record = HOMEBREW_LIBRARY.join("LinkedKegs", name)
end end
def uninstall def uninstall
rmtree rmtree
parent.rmdir_if_possible parent.rmdir_if_possible
opt = HOMEBREW_PREFIX.join("opt", fname) opt = HOMEBREW_PREFIX.join("opt", name)
if opt.symlink? && self == opt.resolved_path if opt.symlink? && self == opt.resolved_path
opt.unlink opt.unlink
opt.parent.rmdir_if_possible opt.parent.rmdir_if_possible
@ -140,12 +142,8 @@ class Keg < Pathname
ObserverPathnameExtension.total ObserverPathnameExtension.total
end end
def fname
parent.basename.to_s
end
def lock def lock
FormulaLock.new(fname).with_lock { yield } FormulaLock.new(name).with_lock { yield }
end end
def linked? def linked?
@ -259,7 +257,7 @@ class Keg < Pathname
end end
def optlink def optlink
from = HOMEBREW_PREFIX.join("opt", fname) from = HOMEBREW_PREFIX.join("opt", name)
if from.symlink? if from.symlink?
from.delete from.delete
elsif from.directory? elsif from.directory?

View File

@ -139,7 +139,7 @@ class Keg < Pathname
if shortpath.exist? and not options[:keg_only] if shortpath.exist? and not options[:keg_only]
shortpath.to_s shortpath.to_s
else else
"#{HOMEBREW_PREFIX}/opt/#{fname}/#{relative_dirname}/#{basename}" HOMEBREW_PREFIX.join("opt", name, relative_dirname, basename).to_s
end end
end end