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 (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(" ")
|
||||
end
|
||||
casks.each do |cask|
|
||||
@ -97,7 +97,7 @@ module Cask
|
||||
next if dep_names.blank?
|
||||
|
||||
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(" ")
|
||||
end
|
||||
return
|
||||
|
||||
@ -454,7 +454,7 @@ module Cask
|
||||
artifacts = @cask.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|
|
||||
if artifact.respond_to?(:uninstall_phase)
|
||||
|
||||
@ -124,7 +124,7 @@ module Homebrew
|
||||
return unless HOMEBREW_CELLAR.exist?
|
||||
|
||||
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
|
||||
|
||||
sig { params(args: CLI::Args).void }
|
||||
|
||||
@ -57,10 +57,10 @@ module Homebrew
|
||||
command_count += tap.command_files.size
|
||||
private_count += 1 if tap.private?
|
||||
end
|
||||
info = Utils.pluralize("tap", tap_count, includecount: true)
|
||||
info = Utils.pluralize("tap", tap_count, include_count: true)
|
||||
info += ", #{private_count} private"
|
||||
info += ", #{Utils.pluralize("formula", formula_count, plural: "e", includecount: true)}"
|
||||
info += ", #{Utils.pluralize("command", command_count, includecount: true)}"
|
||||
info += ", #{Utils.pluralize("formula", formula_count, plural: "e", include_count: true)}"
|
||||
info += ", #{Utils.pluralize("command", command_count, include_count: true)}"
|
||||
info += ", #{Tap::TAP_DIRECTORY.dup.abv}" if Tap::TAP_DIRECTORY.directory?
|
||||
puts info
|
||||
else
|
||||
|
||||
@ -233,7 +233,7 @@ module Homebrew
|
||||
|
||||
unless updated_taps.empty?
|
||||
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
|
||||
end
|
||||
|
||||
@ -656,11 +656,11 @@ class ReporterHub
|
||||
elsif report_all
|
||||
if (changed_formulae = select_formula_or_cask(:M).count) && changed_formulae.positive?
|
||||
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
|
||||
|
||||
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
|
||||
else
|
||||
outdated_formulae = Formula.installed.select(&:outdated?).map(&:name)
|
||||
|
||||
@ -275,21 +275,21 @@ module Homebrew
|
||||
if total_problems_count.positive?
|
||||
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 = []
|
||||
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
|
||||
error_sources << Utils.pluralize("cask", cask_count, includecount: true) if cask_count.positive?
|
||||
error_sources << Utils.pluralize("tap", tap_count, includecount: true) if tap_count.positive?
|
||||
error_sources << Utils.pluralize("cask", cask_count, include_count: true) if cask_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 += " detected"
|
||||
|
||||
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
|
||||
|
||||
ofail errors_summary
|
||||
|
||||
@ -65,7 +65,7 @@ module Homebrew
|
||||
grand_totals[user] = total(results[user])
|
||||
|
||||
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?
|
||||
return
|
||||
end
|
||||
@ -81,7 +81,7 @@ module Homebrew
|
||||
grand_totals[username] = total(results[username])
|
||||
|
||||
puts "#{username} contributed #{Utils.pluralize("time", grand_totals[username].values.sum,
|
||||
includecount: true)} #{time_period(args)}."
|
||||
include_count: true)} #{time_period(args)}."
|
||||
end
|
||||
|
||||
puts generate_maintainers_csv(grand_totals) if args.csv?
|
||||
|
||||
@ -908,7 +908,7 @@ module Homebrew
|
||||
0
|
||||
end
|
||||
|
||||
"#{tap.path} (#{Utils.pluralize("cask", cask_count, includecount: true)})"
|
||||
"#{tap.path} (#{Utils.pluralize("cask", cask_count, include_count: true)})"
|
||||
end
|
||||
end)
|
||||
|
||||
|
||||
@ -199,13 +199,13 @@ module Kernel
|
||||
if seconds > 59
|
||||
minutes = 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?
|
||||
|
||||
res << " "
|
||||
end
|
||||
|
||||
res << Utils.pluralize("second", seconds, includecount: true)
|
||||
res << Utils.pluralize("second", seconds, include_count: true)
|
||||
res.freeze
|
||||
end
|
||||
|
||||
|
||||
@ -327,7 +327,7 @@ module Homebrew
|
||||
if dry_run
|
||||
if (formulae_name_to_install = formulae_to_install.map(&:name))
|
||||
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(" ")
|
||||
|
||||
formula_installers.each do |fi|
|
||||
@ -356,7 +356,7 @@ module Homebrew
|
||||
return if dependencies.empty?
|
||||
|
||||
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)
|
||||
puts formula_names.join(" ")
|
||||
end
|
||||
|
||||
@ -475,15 +475,15 @@ class Tap
|
||||
contents = []
|
||||
|
||||
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
|
||||
|
||||
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
|
||||
|
||||
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
|
||||
|
||||
contents
|
||||
|
||||
@ -72,9 +72,9 @@ describe Utils do
|
||||
end
|
||||
|
||||
it "includes the count when requested" do
|
||||
expect(described_class.pluralize("foo", 0, includecount: true)).to eq("0 foos")
|
||||
expect(described_class.pluralize("foo", 1, includecount: true)).to eq("1 foo")
|
||||
expect(described_class.pluralize("foo", 2, includecount: true)).to eq("2 foos")
|
||||
expect(described_class.pluralize("foo", 0, include_count: true)).to eq("0 foos")
|
||||
expect(described_class.pluralize("foo", 1, include_count: true)).to eq("1 foo")
|
||||
expect(described_class.pluralize("foo", 2, include_count: true)).to eq("2 foos")
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@ -313,7 +313,7 @@ module Homebrew
|
||||
formula_plural = Utils.pluralize("formula", installed_formulae.count, plural: "e")
|
||||
upgrade_verb = dry_run ? "Would upgrade" : "Upgrading"
|
||||
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!
|
||||
formulae_upgrades = upgradeable_dependents.map do |f|
|
||||
name = f.full_specified_name
|
||||
@ -387,7 +387,7 @@ module Homebrew
|
||||
ohai "No broken dependents to reinstall!"
|
||||
else
|
||||
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!
|
||||
puts reinstallable_broken_dependents.map(&:full_specified_name)
|
||||
.join(", ")
|
||||
|
||||
@ -126,12 +126,12 @@ module Utils
|
||||
|
||||
# A lightweight alternative to `ActiveSupport::Inflector.pluralize`:
|
||||
# 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 {
|
||||
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)
|
||||
prefix = includecount ? "#{count} " : ""
|
||||
def self.pluralize(stem, count, plural: "s", singular: "", include_count: false)
|
||||
prefix = include_count ? "#{count} " : ""
|
||||
suffix = (count == 1) ? singular : plural
|
||||
"#{prefix}#{stem}#{suffix}"
|
||||
end
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user