Port more call sites

This commit is contained in:
Douglas Eichelberger 2023-02-24 08:53:04 -08:00
parent eb2b990575
commit 3da68651e5
8 changed files with 29 additions and 23 deletions

View File

@ -172,7 +172,7 @@ module Homebrew
end
if !pinned.empty? && !args.ignore_pinned?
ofail "Not upgrading #{pinned.count} pinned #{"package".pluralize(pinned.count)}:"
ofail "Not upgrading #{pinned.count} pinned #{Utils::Inflection.pluralize("package", pinned.count)}:"
puts pinned.map { |f| "#{f.full_specified_name} #{f.pkg_version}" } * ", "
end
@ -180,7 +180,8 @@ module Homebrew
oh1 "No packages to upgrade"
else
verb = args.dry_run? ? "Would upgrade" : "Upgrading"
oh1 "#{verb} #{formulae_to_install.count} outdated #{"package".pluralize(formulae_to_install.count)}:"
oh1 "#{verb} #{formulae_to_install.count} outdated #{Utils::Inflection.pluralize("package",
formulae_to_install.count)}:"
formulae_upgrades = formulae_to_install.map do |f|
if f.optlinked?
"#{f.full_specified_name} #{Keg.new(f.opt_prefix).version} -> #{f.pkg_version}"

View File

@ -277,19 +277,23 @@ module Homebrew
if total_problems_count.positive?
puts new_formula_problem_lines.map { |s| " #{s}" }
errors_summary = "#{total_problems_count} #{"problem".pluralize(total_problems_count)}"
errors_summary = "#{total_problems_count} #{Utils::Inflection.pluralize("problem", total_problems_count)}"
error_sources = []
error_sources << "#{formula_count} #{"formula".pluralize(formula_count)}" if formula_count.positive?
error_sources << "#{cask_count} #{"cask".pluralize(cask_count)}" if cask_count.positive?
error_sources << "#{tap_count} #{"tap".pluralize(tap_count)}" if tap_count.positive?
if formula_count.positive?
error_sources << "#{formula_count} #{Utils::Inflection.pluralize("formula", formula_count,
plural: "e")}"
end
error_sources << "#{cask_count} #{Utils::Inflection.pluralize("cask", cask_count)}" if cask_count.positive?
error_sources << "#{tap_count} #{Utils::Inflection.pluralize("tap", tap_count)}" if tap_count.positive?
errors_summary += " in #{error_sources.to_sentence}" if error_sources.any?
errors_summary += " detected"
if corrected_problem_count.positive?
errors_summary += ", #{corrected_problem_count} #{"problem".pluralize(corrected_problem_count)} corrected"
errors_summary += ", #{corrected_problem_count} #{Utils::Inflection.pluralize("problem",
corrected_problem_count)} corrected"
end
ofail errors_summary

View File

@ -61,7 +61,7 @@ module Homebrew
return
end
ohai "#{prs.count} matching pull #{"request".pluralize(prs.count)}:"
ohai "#{prs.count} matching pull #{Utils::Inflection.pluralize("request", prs.count)}:"
pr_urls = []
prs.each do |pr|
puts "#{tap.full_name unless tap.core_tap?}##{pr["number"]}: #{pr["title"]}"

View File

@ -568,7 +568,7 @@ end
class UnbottledError < RuntimeError
def initialize(formulae)
msg = +<<~EOS
The following #{"formula".pluralize(formulae.count)} cannot be installed from #{"bottle".pluralize(formulae.count)} and must be
The following #{Utils::Inflection.pluralize("formula", formulae.count, plural: "e")} cannot be installed from #{Utils::Inflection.pluralize("bottle", formulae.count)} and must be
built from source.
#{formulae.to_sentence}
EOS

View File

@ -324,7 +324,7 @@ module Homebrew
if dry_run
if (formulae_name_to_install = formulae_to_install.map(&:name))
plural = "formula".pluralize(formulae_name_to_install.count)
plural = Utils::Inflection.pluralize("formula", formulae_name_to_install.count, plural: "e")
ohai "Would install #{formulae_name_to_install.count} #{plural}:"
puts formulae_name_to_install.join(" ")
@ -354,7 +354,7 @@ module Homebrew
def print_dry_run_dependencies(formula, dependencies, &block)
return if dependencies.empty?
plural = "dependency".pluralize(dependencies.count)
plural = Utils::Inflection.pluralize("dependenc", dependencies.count, plural: "ies", singular: "y")
ohai "Would install #{dependencies.count} #{plural} for #{formula.name}:"
formula_names = dependencies.map(&:first).map(&:to_formula).map(&block)
puts formula_names.join(" ")

View File

@ -475,15 +475,15 @@ class Tap
contents = []
if (command_count = command_files.count).positive?
contents << "#{command_count} #{"command".pluralize(command_count)}"
contents << "#{command_count} #{Utils::Inflection.pluralize("command", command_count)}"
end
if (cask_count = cask_files.count).positive?
contents << "#{cask_count} #{"cask".pluralize(cask_count)}"
contents << "#{cask_count} #{Utils::Inflection.pluralize("cask", cask_count)}"
end
if (formula_count = formula_files.count).positive?
contents << "#{formula_count} #{"formula".pluralize(formula_count)}"
contents << "#{formula_count} #{Utils::Inflection.pluralize("formula", formula_count, plural: "e")}"
end
contents

View File

@ -52,7 +52,7 @@ module Homebrew
if rack.directory?
versions = rack.subdirs.map(&:basename)
puts <<~EOS
#{keg.name} #{versions.to_sentence} #{"is".pluralize(versions.count)} still installed.
#{keg.name} #{versions.to_sentence} #{Utils::Inflection.pluralize("", versions.count, plural: "are", singular: "is")} still installed.
To remove all versions, run:
brew uninstall --force #{keg.name}
EOS
@ -136,8 +136,9 @@ module Homebrew
end
def are_required_by_deps
"#{"is".pluralize(reqs.count)} required by #{deps.to_sentence}, " \
"which #{"is".pluralize(deps.count)} currently installed"
"#{Utils::Inflection.pluralize("", reqs.count, plural: "are",
singular: "is")} required by #{deps.to_sentence}, " \
"which #{Utils::Inflection.pluralize("", deps.count, plural: "are", singular: "is")} currently installed"
end
end
@ -157,7 +158,7 @@ module Homebrew
def output
ofail <<~EOS
Refusing to uninstall #{reqs.to_sentence}
because #{"it".pluralize(reqs.count)} #{are_required_by_deps}.
because #{Utils::Inflection.pluralize("", reqs.count, plural: "they", singular: "it")} #{are_required_by_deps}.
You can override this and force removal with:
#{sample_command}
EOS

View File

@ -299,7 +299,7 @@ module Homebrew
.sort { |a, b| depends_on(a, b) }
if pinned_dependents.present?
plural = "dependent".pluralize(pinned_dependents.count)
plural = Utils::Inflection.pluralize("dependent", pinned_dependents.count)
ohai "Not upgrading #{pinned_dependents.count} pinned #{plural}:"
puts(pinned_dependents.map do |f|
"#{f.full_specified_name} #{f.pkg_version}"
@ -310,8 +310,8 @@ module Homebrew
if upgradeable_dependents.blank?
ohai "No outdated dependents to upgrade!" unless dry_run
else
dependent_plural = "dependent".pluralize(upgradeable_dependents.count)
formula_plural = "formula".pluralize(installed_formulae.count)
dependent_plural = Utils::Inflection.pluralize("dependent", upgradeable_dependents.count)
formula_plural = Utils::Inflection.pluralize("formula", installed_formulae.count, plural: "e")
upgrade_verb = dry_run ? "Would upgrade" : "Upgrading"
ohai "#{upgrade_verb} #{upgradeable_dependents.count} #{dependent_plural} of upgraded #{formula_plural}:"
Upgrade.puts_no_installed_dependents_check_disable_message_if_not_already!
@ -375,7 +375,7 @@ module Homebrew
# Print the pinned dependents.
if outdated_pinned_broken_dependents.present?
count = outdated_pinned_broken_dependents.count
plural = "dependent".pluralize(outdated_pinned_broken_dependents.count)
plural = Utils::Inflection.pluralize("dependent", outdated_pinned_broken_dependents.count)
onoe "Not reinstalling #{count} broken and outdated, but pinned #{plural}:"
$stderr.puts(outdated_pinned_broken_dependents.map do |f|
"#{f.full_specified_name} #{f.pkg_version}"
@ -387,7 +387,7 @@ module Homebrew
ohai "No broken dependents to reinstall!"
else
count = reinstallable_broken_dependents.count
plural = "dependent".pluralize(reinstallable_broken_dependents.count)
plural = Utils::Inflection.pluralize("dependent", reinstallable_broken_dependents.count)
ohai "Reinstalling #{count} #{plural} with broken linkage from source:"
Upgrade.puts_no_installed_dependents_check_disable_message_if_not_already!
puts reinstallable_broken_dependents.map(&:full_specified_name)