change includecount to include_count for readability
This commit is contained in:
parent
e5fba88035
commit
b776fb32de
@ -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)
|
||||||
ohai "Would install #{::Utils.pluralize("cask", casks_to_install.count, includecount: true)}:"
|
ohai "Would install #{::Utils.pluralize("cask", casks_to_install.count, include_count: true)}:"
|
||||||
puts casks_to_install.map(&:full_name).join(" ")
|
puts casks_to_install.map(&:full_name).join(" ")
|
||||||
end
|
end
|
||||||
casks.each do |cask|
|
casks.each do |cask|
|
||||||
@ -97,7 +97,7 @@ module Cask
|
|||||||
next if dep_names.blank?
|
next if dep_names.blank?
|
||||||
|
|
||||||
ohai "Would install #{::Utils.pluralize("dependenc", dep_names.count, plural: "ies", singular: "y",
|
ohai "Would install #{::Utils.pluralize("dependenc", dep_names.count, plural: "ies", singular: "y",
|
||||||
includecount: true)} for #{cask.full_name}:"
|
include_count: true)} for #{cask.full_name}:"
|
||||||
puts dep_names.join(" ")
|
puts dep_names.join(" ")
|
||||||
end
|
end
|
||||||
return
|
return
|
||||||
|
|||||||
@ -454,7 +454,7 @@ module Cask
|
|||||||
artifacts = @cask.artifacts
|
artifacts = @cask.artifacts
|
||||||
|
|
||||||
odebug "Uninstalling artifacts"
|
odebug "Uninstalling artifacts"
|
||||||
odebug "#{::Utils.pluralize("artifact", artifacts.length, includecount: true)} defined", artifacts
|
odebug "#{::Utils.pluralize("artifact", artifacts.length, include_count: true)} defined", artifacts
|
||||||
|
|
||||||
artifacts.each do |artifact|
|
artifacts.each do |artifact|
|
||||||
if artifact.respond_to?(:uninstall_phase)
|
if artifact.respond_to?(:uninstall_phase)
|
||||||
|
|||||||
@ -124,7 +124,7 @@ module Homebrew
|
|||||||
return unless HOMEBREW_CELLAR.exist?
|
return unless HOMEBREW_CELLAR.exist?
|
||||||
|
|
||||||
count = Formula.racks.length
|
count = Formula.racks.length
|
||||||
puts "#{Utils.pluralize("keg", count, includecount: true)}, #{HOMEBREW_CELLAR.dup.abv}"
|
puts "#{Utils.pluralize("keg", count, include_count: true)}, #{HOMEBREW_CELLAR.dup.abv}"
|
||||||
end
|
end
|
||||||
|
|
||||||
sig { params(args: CLI::Args).void }
|
sig { params(args: CLI::Args).void }
|
||||||
|
|||||||
@ -57,10 +57,10 @@ module Homebrew
|
|||||||
command_count += tap.command_files.size
|
command_count += tap.command_files.size
|
||||||
private_count += 1 if tap.private?
|
private_count += 1 if tap.private?
|
||||||
end
|
end
|
||||||
info = Utils.pluralize("tap", tap_count, includecount: true)
|
info = Utils.pluralize("tap", tap_count, include_count: true)
|
||||||
info += ", #{private_count} private"
|
info += ", #{private_count} private"
|
||||||
info += ", #{Utils.pluralize("formula", formula_count, plural: "e", includecount: true)}"
|
info += ", #{Utils.pluralize("formula", formula_count, plural: "e", include_count: true)}"
|
||||||
info += ", #{Utils.pluralize("command", command_count, includecount: true)}"
|
info += ", #{Utils.pluralize("command", command_count, include_count: true)}"
|
||||||
info += ", #{Tap::TAP_DIRECTORY.dup.abv}" if Tap::TAP_DIRECTORY.directory?
|
info += ", #{Tap::TAP_DIRECTORY.dup.abv}" if Tap::TAP_DIRECTORY.directory?
|
||||||
puts info
|
puts info
|
||||||
else
|
else
|
||||||
|
|||||||
@ -233,7 +233,7 @@ module Homebrew
|
|||||||
|
|
||||||
unless updated_taps.empty?
|
unless updated_taps.empty?
|
||||||
auto_update_header args: args
|
auto_update_header args: args
|
||||||
puts "Updated #{Utils.pluralize("tap", updated_taps.count, includecount: true)} (#{updated_taps.to_sentence})."
|
puts "Updated #{Utils.pluralize("tap", updated_taps.count, include_count: true)} (#{updated_taps.to_sentence})."
|
||||||
updated = true
|
updated = true
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -656,11 +656,11 @@ class ReporterHub
|
|||||||
elsif report_all
|
elsif report_all
|
||||||
if (changed_formulae = select_formula_or_cask(:M).count) && changed_formulae.positive?
|
if (changed_formulae = select_formula_or_cask(:M).count) && changed_formulae.positive?
|
||||||
ohai "Modified Formulae",
|
ohai "Modified Formulae",
|
||||||
"Modified #{Utils.pluralize("formula", changed_formulae, plural: "e", includecount: true)}."
|
"Modified #{Utils.pluralize("formula", changed_formulae, plural: "e", include_count: true)}."
|
||||||
end
|
end
|
||||||
|
|
||||||
if (changed_casks = select_formula_or_cask(:MC).count) && changed_casks.positive?
|
if (changed_casks = select_formula_or_cask(:MC).count) && changed_casks.positive?
|
||||||
ohai "Modified Casks", "Modified #{Utils.pluralize("cask", changed_casks, includecount: true)}."
|
ohai "Modified Casks", "Modified #{Utils.pluralize("cask", changed_casks, include_count: true)}."
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
outdated_formulae = Formula.installed.select(&:outdated?).map(&:name)
|
outdated_formulae = Formula.installed.select(&:outdated?).map(&:name)
|
||||||
|
|||||||
@ -275,21 +275,21 @@ module Homebrew
|
|||||||
if total_problems_count.positive?
|
if total_problems_count.positive?
|
||||||
puts new_formula_problem_lines.map { |s| " #{s}" }
|
puts new_formula_problem_lines.map { |s| " #{s}" }
|
||||||
|
|
||||||
errors_summary = Utils.pluralize("problem", total_problems_count, includecount: true)
|
errors_summary = Utils.pluralize("problem", total_problems_count, include_count: true)
|
||||||
|
|
||||||
error_sources = []
|
error_sources = []
|
||||||
if formula_count.positive?
|
if formula_count.positive?
|
||||||
error_sources << Utils.pluralize("formula", formula_count, plural: "e", includecount: true)
|
error_sources << Utils.pluralize("formula", formula_count, plural: "e", include_count: true)
|
||||||
end
|
end
|
||||||
error_sources << Utils.pluralize("cask", cask_count, includecount: true) if cask_count.positive?
|
error_sources << Utils.pluralize("cask", cask_count, include_count: true) if cask_count.positive?
|
||||||
error_sources << Utils.pluralize("tap", tap_count, includecount: true) if tap_count.positive?
|
error_sources << Utils.pluralize("tap", tap_count, include_count: true) if tap_count.positive?
|
||||||
|
|
||||||
errors_summary += " in #{error_sources.to_sentence}" if error_sources.any?
|
errors_summary += " in #{error_sources.to_sentence}" if error_sources.any?
|
||||||
|
|
||||||
errors_summary += " detected"
|
errors_summary += " detected"
|
||||||
|
|
||||||
if corrected_problem_count.positive?
|
if corrected_problem_count.positive?
|
||||||
errors_summary += ", #{Utils.pluralize("problem", corrected_problem_count, includecount: true)} corrected"
|
errors_summary += ", #{Utils.pluralize("problem", corrected_problem_count, include_count: true)} corrected"
|
||||||
end
|
end
|
||||||
|
|
||||||
ofail errors_summary
|
ofail errors_summary
|
||||||
|
|||||||
@ -65,7 +65,7 @@ module Homebrew
|
|||||||
grand_totals[user] = total(results[user])
|
grand_totals[user] = total(results[user])
|
||||||
|
|
||||||
puts "#{user} contributed #{Utils.pluralize("time", grand_totals[user].values.sum,
|
puts "#{user} contributed #{Utils.pluralize("time", grand_totals[user].values.sum,
|
||||||
includecount: true)} #{time_period(args)}."
|
include_count: true)} #{time_period(args)}."
|
||||||
puts generate_csv(T.must(user), results[user], grand_totals[user]) if args.csv?
|
puts generate_csv(T.must(user), results[user], grand_totals[user]) if args.csv?
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
@ -81,7 +81,7 @@ module Homebrew
|
|||||||
grand_totals[username] = total(results[username])
|
grand_totals[username] = total(results[username])
|
||||||
|
|
||||||
puts "#{username} contributed #{Utils.pluralize("time", grand_totals[username].values.sum,
|
puts "#{username} contributed #{Utils.pluralize("time", grand_totals[username].values.sum,
|
||||||
includecount: true)} #{time_period(args)}."
|
include_count: true)} #{time_period(args)}."
|
||||||
end
|
end
|
||||||
|
|
||||||
puts generate_maintainers_csv(grand_totals) if args.csv?
|
puts generate_maintainers_csv(grand_totals) if args.csv?
|
||||||
|
|||||||
@ -908,7 +908,7 @@ module Homebrew
|
|||||||
0
|
0
|
||||||
end
|
end
|
||||||
|
|
||||||
"#{tap.path} (#{Utils.pluralize("cask", cask_count, includecount: true)})"
|
"#{tap.path} (#{Utils.pluralize("cask", cask_count, include_count: true)})"
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
|||||||
@ -199,13 +199,13 @@ module Kernel
|
|||||||
if seconds > 59
|
if seconds > 59
|
||||||
minutes = seconds / 60
|
minutes = seconds / 60
|
||||||
seconds %= 60
|
seconds %= 60
|
||||||
res = +Utils.pluralize("minute", minutes, includecount: true)
|
res = +Utils.pluralize("minute", minutes, include_count: true)
|
||||||
return res.freeze if seconds.zero?
|
return res.freeze if seconds.zero?
|
||||||
|
|
||||||
res << " "
|
res << " "
|
||||||
end
|
end
|
||||||
|
|
||||||
res << Utils.pluralize("second", seconds, includecount: true)
|
res << Utils.pluralize("second", seconds, include_count: true)
|
||||||
res.freeze
|
res.freeze
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@ -327,7 +327,7 @@ module Homebrew
|
|||||||
if dry_run
|
if dry_run
|
||||||
if (formulae_name_to_install = formulae_to_install.map(&:name))
|
if (formulae_name_to_install = formulae_to_install.map(&:name))
|
||||||
ohai "Would install #{Utils.pluralize("formula", formulae_name_to_install.count,
|
ohai "Would install #{Utils.pluralize("formula", formulae_name_to_install.count,
|
||||||
plural: "e", includecount: true)}:"
|
plural: "e", include_count: true)}:"
|
||||||
puts formulae_name_to_install.join(" ")
|
puts formulae_name_to_install.join(" ")
|
||||||
|
|
||||||
formula_installers.each do |fi|
|
formula_installers.each do |fi|
|
||||||
@ -356,7 +356,7 @@ module Homebrew
|
|||||||
return if dependencies.empty?
|
return if dependencies.empty?
|
||||||
|
|
||||||
ohai "Would install #{Utils.pluralize("dependenc", dependencies.count, plural: "ies", singular: "y",
|
ohai "Would install #{Utils.pluralize("dependenc", dependencies.count, plural: "ies", singular: "y",
|
||||||
includecount: true)} for #{formula.name}:"
|
include_count: true)} for #{formula.name}:"
|
||||||
formula_names = dependencies.map(&:first).map(&:to_formula).map(&block)
|
formula_names = dependencies.map(&:first).map(&:to_formula).map(&block)
|
||||||
puts formula_names.join(" ")
|
puts formula_names.join(" ")
|
||||||
end
|
end
|
||||||
|
|||||||
@ -475,15 +475,15 @@ class Tap
|
|||||||
contents = []
|
contents = []
|
||||||
|
|
||||||
if (command_count = command_files.count).positive?
|
if (command_count = command_files.count).positive?
|
||||||
contents << Utils.pluralize("command", command_count, includecount: true)
|
contents << Utils.pluralize("command", command_count, include_count: true)
|
||||||
end
|
end
|
||||||
|
|
||||||
if (cask_count = cask_files.count).positive?
|
if (cask_count = cask_files.count).positive?
|
||||||
contents << Utils.pluralize("cask", cask_count, includecount: true)
|
contents << Utils.pluralize("cask", cask_count, include_count: true)
|
||||||
end
|
end
|
||||||
|
|
||||||
if (formula_count = formula_files.count).positive?
|
if (formula_count = formula_files.count).positive?
|
||||||
contents << Utils.pluralize("formula", formula_count, plural: "e", includecount: true)
|
contents << Utils.pluralize("formula", formula_count, plural: "e", include_count: true)
|
||||||
end
|
end
|
||||||
|
|
||||||
contents
|
contents
|
||||||
|
|||||||
@ -72,9 +72,9 @@ describe Utils do
|
|||||||
end
|
end
|
||||||
|
|
||||||
it "includes the count when requested" do
|
it "includes the count when requested" do
|
||||||
expect(described_class.pluralize("foo", 0, includecount: true)).to eq("0 foos")
|
expect(described_class.pluralize("foo", 0, include_count: true)).to eq("0 foos")
|
||||||
expect(described_class.pluralize("foo", 1, includecount: true)).to eq("1 foo")
|
expect(described_class.pluralize("foo", 1, include_count: true)).to eq("1 foo")
|
||||||
expect(described_class.pluralize("foo", 2, includecount: true)).to eq("2 foos")
|
expect(described_class.pluralize("foo", 2, include_count: true)).to eq("2 foos")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@ -313,7 +313,7 @@ module Homebrew
|
|||||||
formula_plural = Utils.pluralize("formula", installed_formulae.count, plural: "e")
|
formula_plural = Utils.pluralize("formula", installed_formulae.count, plural: "e")
|
||||||
upgrade_verb = dry_run ? "Would upgrade" : "Upgrading"
|
upgrade_verb = dry_run ? "Would upgrade" : "Upgrading"
|
||||||
ohai "#{upgrade_verb} #{Utils.pluralize("dependent", upgradeable_dependents.count,
|
ohai "#{upgrade_verb} #{Utils.pluralize("dependent", upgradeable_dependents.count,
|
||||||
includecount: true)} of upgraded #{formula_plural}:"
|
include_count: true)} of upgraded #{formula_plural}:"
|
||||||
Upgrade.puts_no_installed_dependents_check_disable_message_if_not_already!
|
Upgrade.puts_no_installed_dependents_check_disable_message_if_not_already!
|
||||||
formulae_upgrades = upgradeable_dependents.map do |f|
|
formulae_upgrades = upgradeable_dependents.map do |f|
|
||||||
name = f.full_specified_name
|
name = f.full_specified_name
|
||||||
@ -387,7 +387,7 @@ module Homebrew
|
|||||||
ohai "No broken dependents to reinstall!"
|
ohai "No broken dependents to reinstall!"
|
||||||
else
|
else
|
||||||
ohai "Reinstalling #{Utils.pluralize("dependent", reinstallable_broken_dependents.count,
|
ohai "Reinstalling #{Utils.pluralize("dependent", reinstallable_broken_dependents.count,
|
||||||
includecount: true)} with broken linkage from source:"
|
include_count: true)} with broken linkage from source:"
|
||||||
Upgrade.puts_no_installed_dependents_check_disable_message_if_not_already!
|
Upgrade.puts_no_installed_dependents_check_disable_message_if_not_already!
|
||||||
puts reinstallable_broken_dependents.map(&:full_specified_name)
|
puts reinstallable_broken_dependents.map(&:full_specified_name)
|
||||||
.join(", ")
|
.join(", ")
|
||||||
|
|||||||
@ -126,12 +126,12 @@ module Utils
|
|||||||
|
|
||||||
# A lightweight alternative to `ActiveSupport::Inflector.pluralize`:
|
# A lightweight alternative to `ActiveSupport::Inflector.pluralize`:
|
||||||
# Combines `stem` with the `singular` or `plural` suffix based on `count`.
|
# Combines `stem` with the `singular` or `plural` suffix based on `count`.
|
||||||
# Adds a prefix of the count value if `includecount` is set to true.
|
# Adds a prefix of the count value if `include_count` is set to true.
|
||||||
sig {
|
sig {
|
||||||
params(stem: String, count: Integer, plural: String, singular: String, includecount: T::Boolean).returns(String)
|
params(stem: String, count: Integer, plural: String, singular: String, include_count: T::Boolean).returns(String)
|
||||||
}
|
}
|
||||||
def self.pluralize(stem, count, plural: "s", singular: "", includecount: false)
|
def self.pluralize(stem, count, plural: "s", singular: "", include_count: false)
|
||||||
prefix = includecount ? "#{count} " : ""
|
prefix = include_count ? "#{count} " : ""
|
||||||
suffix = (count == 1) ? singular : plural
|
suffix = (count == 1) ? singular : plural
|
||||||
"#{prefix}#{stem}#{suffix}"
|
"#{prefix}#{stem}#{suffix}"
|
||||||
end
|
end
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user