Change to pluralize, port more call sites
This commit is contained in:
parent
0438a3a538
commit
37015b6b08
@ -85,7 +85,7 @@ module Cask
|
|||||||
|
|
||||||
if dry_run
|
if dry_run
|
||||||
if (casks_to_install = casks.reject(&:installed?).presence)
|
if (casks_to_install = casks.reject(&:installed?).presence)
|
||||||
plural = ::Utils::Inflection.number(casks_to_install.count, "cask")
|
plural = ::Utils::Inflection.pluralize("cask", casks_to_install.count)
|
||||||
ohai "Would install #{casks_to_install.count} #{plural}:"
|
ohai "Would install #{casks_to_install.count} #{plural}:"
|
||||||
puts casks_to_install.map(&:full_name).join(" ")
|
puts casks_to_install.map(&:full_name).join(" ")
|
||||||
end
|
end
|
||||||
@ -97,7 +97,7 @@ module Cask
|
|||||||
.map(&:name)
|
.map(&:name)
|
||||||
next if dep_names.blank?
|
next if dep_names.blank?
|
||||||
|
|
||||||
plural = ::Utils::Inflection.number(dep_names.count, "dependenc", "ies", "y")
|
plural = ::Utils::Inflection.pluralize("dependenc", dep_names.count, plural: "ies", singular: "y")
|
||||||
ohai "Would install #{dep_names.count} #{plural} for #{cask.full_name}:"
|
ohai "Would install #{dep_names.count} #{plural} for #{cask.full_name}:"
|
||||||
puts dep_names.join(" ")
|
puts dep_names.join(" ")
|
||||||
end
|
end
|
||||||
|
@ -46,7 +46,7 @@ module Cask
|
|||||||
next if (versions = cask.versions).empty?
|
next if (versions = cask.versions).empty?
|
||||||
|
|
||||||
puts <<~EOS
|
puts <<~EOS
|
||||||
#{cask} #{versions.to_sentence} #{::Utils::Inflection.number(versions.count, "", "are", "is")} still installed.
|
#{cask} #{versions.to_sentence} #{::Utils::Inflection.pluralize("", versions.count, plural: "are", singular: "is")} still installed.
|
||||||
Remove #{(versions.count == 1) ? "it" : "them all"} with `brew uninstall --cask --force #{cask}`.
|
Remove #{(versions.count == 1) ? "it" : "them all"} with `brew uninstall --cask --force #{cask}`.
|
||||||
EOS
|
EOS
|
||||||
end
|
end
|
||||||
|
@ -121,7 +121,7 @@ module Cask
|
|||||||
|
|
||||||
if manual_installer_casks.present?
|
if manual_installer_casks.present?
|
||||||
count = manual_installer_casks.count
|
count = manual_installer_casks.count
|
||||||
ofail "Not upgrading #{count} `installer manual` #{::Utils::Inflection.number(versions.count, "cask")}."
|
ofail "Not upgrading #{count} `installer manual` #{::Utils::Inflection.pluralize("cask", versions.count)}."
|
||||||
puts manual_installer_casks.map(&:to_s)
|
puts manual_installer_casks.map(&:to_s)
|
||||||
outdated_casks -= manual_installer_casks
|
outdated_casks -= manual_installer_casks
|
||||||
end
|
end
|
||||||
@ -142,7 +142,7 @@ module Cask
|
|||||||
end
|
end
|
||||||
|
|
||||||
verb = dry_run ? "Would upgrade" : "Upgrading"
|
verb = dry_run ? "Would upgrade" : "Upgrading"
|
||||||
oh1 "#{verb} #{outdated_casks.count} outdated #{::Utils::Inflection.number(outdated_casks.count, "package")}:"
|
oh1 "#{verb} #{outdated_casks.count} outdated #{::Utils::Inflection.pluralize("package", outdated_casks.count)}:"
|
||||||
|
|
||||||
caught_exceptions = []
|
caught_exceptions = []
|
||||||
|
|
||||||
|
@ -584,7 +584,7 @@ module Homebrew
|
|||||||
formulae_names = removable_formulae.map(&:full_name).sort
|
formulae_names = removable_formulae.map(&:full_name).sort
|
||||||
|
|
||||||
verb = dry_run ? "Would autoremove" : "Autoremoving"
|
verb = dry_run ? "Would autoremove" : "Autoremoving"
|
||||||
oh1 "#{verb} #{formulae_names.count} unneeded #{"formula".pluralize(formulae_names.count)}:"
|
oh1 "#{verb} #{formulae_names.count} unneeded #{Utils::Inflection.pluralize("formula", formulae_names.count, plural: "e")}:"
|
||||||
puts formulae_names.join("\n")
|
puts formulae_names.join("\n")
|
||||||
return if dry_run
|
return if dry_run
|
||||||
|
|
||||||
|
@ -684,7 +684,7 @@ module Homebrew
|
|||||||
arg_types = types.map { |type| type.to_s.tr("_", " ") }
|
arg_types = types.map { |type| type.to_s.tr("_", " ") }
|
||||||
.to_sentence two_words_connector: " or ", last_word_connector: " or "
|
.to_sentence two_words_connector: " or ", last_word_connector: " or "
|
||||||
|
|
||||||
"This command does not take more than #{maximum} #{arg_types} #{"argument".pluralize(maximum)}."
|
"This command does not take more than #{maximum} #{arg_types} #{Utils::Inflection.pluralize("argument", maximum)}."
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -698,7 +698,7 @@ module Homebrew
|
|||||||
arg_types = types.map { |type| type.to_s.tr("_", " ") }
|
arg_types = types.map { |type| type.to_s.tr("_", " ") }
|
||||||
.to_sentence two_words_connector: " or ", last_word_connector: " or "
|
.to_sentence two_words_connector: " or ", last_word_connector: " or "
|
||||||
|
|
||||||
super "This command requires at least #{minimum} #{arg_types} #{"argument".pluralize(minimum)}."
|
super "This command requires at least #{minimum} #{arg_types} #{Utils::Inflection.pluralize("argument", minimum)}."
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -711,7 +711,7 @@ module Homebrew
|
|||||||
arg_types = types.map { |type| type.to_s.tr("_", " ") }
|
arg_types = types.map { |type| type.to_s.tr("_", " ") }
|
||||||
.to_sentence two_words_connector: " or ", last_word_connector: " or "
|
.to_sentence two_words_connector: " or ", last_word_connector: " or "
|
||||||
|
|
||||||
super "This command requires exactly #{minimum} #{arg_types} #{"argument".pluralize(minimum)}."
|
super "This command requires exactly #{minimum} #{arg_types} #{Utils::Inflection.pluralize("argument", minimum)}."
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -906,11 +906,11 @@ module Homebrew
|
|||||||
0
|
0
|
||||||
end
|
end
|
||||||
|
|
||||||
"#{tap.path} (#{cask_count} #{"cask".pluralize(cask_count)})"
|
"#{tap.path} (#{cask_count} #{Utils::Inflection.pluralize("cask", cask_count)})"
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
|
|
||||||
taps = "tap".pluralize error_tap_paths.count
|
taps = Utils::Inflection.pluralize("tap", error_tap_paths.count)
|
||||||
"Unable to read from cask #{taps}: #{error_tap_paths.to_sentence}" if error_tap_paths.present?
|
"Unable to read from cask #{taps}: #{error_tap_paths.to_sentence}" if error_tap_paths.present?
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -8,9 +8,9 @@ module Utils
|
|||||||
module Inflection
|
module Inflection
|
||||||
extend T::Sig
|
extend T::Sig
|
||||||
|
|
||||||
# Combines `stem`` with the `singular`` or `plural` suffix based on `count`.
|
# Combines `stem` with the `singular` or `plural` suffix based on `count`.
|
||||||
sig { params(count: Integer, stem: String, plural: String, singular: String).returns(String) }
|
sig { params(stem: String, count: Integer, plural: String, singular: String).returns(String) }
|
||||||
def self.number(count, stem, plural = "s", singular = "")
|
def self.pluralize(stem, count, plural: "s", singular: "")
|
||||||
suffix = (count == 1) ? singular : plural
|
suffix = (count == 1) ? singular : plural
|
||||||
"#{stem}#{suffix}"
|
"#{stem}#{suffix}"
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user