Consistently call name on formula instead of relying on to_s

This commit is contained in:
Jack Nagel 2014-09-14 11:18:55 -05:00
parent 976bb9b057
commit f3b7c3236b
6 changed files with 19 additions and 18 deletions

View File

@ -172,7 +172,7 @@ class Build
end end
Keg.new(path).optlink Keg.new(path).optlink
rescue StandardError rescue StandardError
raise "#{f.opt_prefix} not present or broken\nPlease reinstall #{f}. Sorry :(" raise "#{f.opt_prefix} not present or broken\nPlease reinstall #{f.name}. Sorry :("
end end
end end

View File

@ -29,7 +29,7 @@ module Homebrew
# Building head-only without --HEAD is an error # Building head-only without --HEAD is an error
if not ARGV.build_head? and f.stable.nil? if not ARGV.build_head? and f.stable.nil?
raise CannotInstallFormulaError, <<-EOS.undent raise CannotInstallFormulaError, <<-EOS.undent
#{f} is a head-only formula #{f.name} is a head-only formula
Install with `brew install --HEAD #{f.name}` Install with `brew install --HEAD #{f.name}`
EOS EOS
end end

View File

@ -11,10 +11,10 @@ module Homebrew
else else
outdated = ARGV.formulae.select do |f| outdated = ARGV.formulae.select do |f|
if f.installed? if f.installed?
onoe "#{f}-#{f.installed_version} already installed" onoe "#{f.name}-#{f.installed_version} already installed"
false false
elsif not f.rack.directory? or f.rack.subdirs.empty? elsif not f.rack.directory? or f.rack.subdirs.empty?
onoe "#{f} not installed" onoe "#{f.name} not installed"
false false
else else
true true

View File

@ -85,7 +85,7 @@ class FormulaAlreadyInstalledError < RuntimeError; end
class FormulaInstallationAlreadyAttemptedError < RuntimeError class FormulaInstallationAlreadyAttemptedError < RuntimeError
def initialize(formula) def initialize(formula)
super "Formula installation already attempted: #{formula}" super "Formula installation already attempted: #{formula.name}"
end end
end end
@ -175,7 +175,7 @@ class BuildError < RuntimeError
Homebrew.dump_build_env(env) Homebrew.dump_build_env(env)
puts puts
onoe "#{formula.name} #{formula.version} did not build" onoe "#{formula.name} #{formula.version} did not build"
unless (logs = Dir["#{HOMEBREW_LOGS}/#{formula}/*"]).empty? unless (logs = Dir["#{HOMEBREW_LOGS}/#{formula.name}/*"]).empty?
puts "Logs:" puts "Logs:"
puts logs.map{|fn| " #{fn}"}.join("\n") puts logs.map{|fn| " #{fn}"}.join("\n")
end end
@ -239,7 +239,7 @@ end
class ResourceMissingError < ArgumentError class ResourceMissingError < ArgumentError
def initialize(formula, resource) def initialize(formula, resource)
super "#{formula} does not define resource #{resource.inspect}" super "#{formula.name} does not define resource #{resource.inspect}"
end end
end end

View File

@ -60,7 +60,7 @@ class FormulaInstaller
unless f.bottle.compatible_cellar? unless f.bottle.compatible_cellar?
if install_bottle_options[:warn] if install_bottle_options[:warn]
opoo "Building source; cellar of #{f}'s bottle is #{f.bottle.cellar}" opoo "Building source; cellar of #{f.name}'s bottle is #{f.bottle.cellar}"
end end
return false return false
end end
@ -101,7 +101,7 @@ class FormulaInstaller
raise FormulaInstallationAlreadyAttemptedError, f if @@attempted.include? f raise FormulaInstallationAlreadyAttemptedError, f if @@attempted.include? f
if f.installed? if f.installed?
msg = "#{f}-#{f.installed_version} already installed" msg = "#{f.name}-#{f.installed_version} already installed"
msg << ", it's just not linked" unless f.linked_keg.symlink? or f.keg_only? msg << ", it's just not linked" unless f.linked_keg.symlink? or f.keg_only?
raise FormulaAlreadyInstalledError, msg raise FormulaAlreadyInstalledError, msg
end end
@ -111,7 +111,7 @@ class FormulaInstaller
dep.installed? and not dep.keg_only? and not dep.linked_keg.directory? dep.installed? and not dep.keg_only? and not dep.linked_keg.directory?
end end
raise CannotInstallFormulaError, raise CannotInstallFormulaError,
"You must `brew link #{unlinked_deps*' '}' before #{f} can be installed" unless unlinked_deps.empty? "You must `brew link #{unlinked_deps*' '}' before #{f.name} can be installed" unless unlinked_deps.empty?
end end
end end
@ -134,8 +134,8 @@ class FormulaInstaller
if f.linked_keg.directory? if f.linked_keg.directory?
# some other version is already installed *and* linked # some other version is already installed *and* linked
raise CannotInstallFormulaError, <<-EOS.undent raise CannotInstallFormulaError, <<-EOS.undent
#{f}-#{f.linked_keg.resolved_path.basename} already installed #{f.name}-#{f.linked_keg.resolved_path.basename} already installed
To install this version, first `brew unlink #{f}' To install this version, first `brew unlink #{f.name}'
EOS EOS
end end
@ -149,7 +149,7 @@ class FormulaInstaller
raise "Unrecognized architecture for --bottle-arch: #{arch}" raise "Unrecognized architecture for --bottle-arch: #{arch}"
end end
oh1 "Installing #{Tty.green}#{f}#{Tty.reset}" if show_header? oh1 "Installing #{Tty.green}#{f.name}#{Tty.reset}" if show_header?
@@attempted << f @@attempted << f
@ -216,7 +216,7 @@ class FormulaInstaller
deps = expand_dependencies(req_deps + f.deps) deps = expand_dependencies(req_deps + f.deps)
if deps.empty? and only_deps? if deps.empty? and only_deps?
puts "All dependencies for #{f} are satisfied." puts "All dependencies for #{f.name} are satisfied."
else else
install_dependencies(deps) install_dependencies(deps)
end end
@ -316,7 +316,7 @@ class FormulaInstaller
def install_dependencies(deps) def install_dependencies(deps)
if deps.length > 1 if deps.length > 1
oh1 "Installing dependencies for #{f}: #{Tty.green}#{deps.map(&:first)*", "}#{Tty.reset}" oh1 "Installing dependencies for #{f.name}: #{Tty.green}#{deps.map(&:first)*", "}#{Tty.reset}"
end end
deps.each { |dep, options| install_dependency(dep, options) } deps.each { |dep, options| install_dependency(dep, options) }
@ -360,7 +360,7 @@ class FormulaInstaller
fi.verbose = verbose? unless verbose == :quieter fi.verbose = verbose? unless verbose == :quieter
fi.debug = debug? fi.debug = debug?
fi.prelude fi.prelude
oh1 "Installing #{f} dependency: #{Tty.green}#{dep.name}#{Tty.reset}" oh1 "Installing #{f.name} dependency: #{Tty.green}#{dep.name}#{Tty.reset}"
fi.install fi.install
fi.caveats fi.caveats
fi.finish fi.finish
@ -466,7 +466,7 @@ class FormulaInstaller
end end
def build def build
FileUtils.rm Dir["#{HOMEBREW_LOGS}/#{f}/*"] FileUtils.rm Dir["#{HOMEBREW_LOGS}/#{f.name}/*"]
@start_time = Time.now @start_time = Time.now
@ -530,7 +530,7 @@ class FormulaInstaller
keg.optlink keg.optlink
rescue Keg::LinkError => e rescue Keg::LinkError => e
onoe "Failed to create #{f.opt_prefix}" onoe "Failed to create #{f.opt_prefix}"
puts "Things that depend on #{f} will probably not build." puts "Things that depend on #{f.name} will probably not build."
puts e puts e
end end
return return

View File

@ -19,6 +19,7 @@ class SoftwareSpecTests < Homebrew::TestCase
end end
def test_raises_when_accessing_missing_resources def test_raises_when_accessing_missing_resources
@spec.owner = Class.new { def name; "test"; end }.new
assert_raises(ResourceMissingError) { @spec.resource('foo') } assert_raises(ResourceMissingError) { @spec.resource('foo') }
end end