mirror of
https://github.com/Homebrew/brew.git
synced 2025-07-14 16:09:03 +08:00
Tidy up
This commit is contained in:
parent
1ab278f74c
commit
f9f73f3ef6
@ -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.pluralize("", versions.count, plural: "are", singular: "is")} still installed.
|
#{cask} #{versions.to_sentence} #{versions.count == 1 ? "is" : "are"} 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
|
||||||
|
@ -142,8 +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.pluralize("package",
|
oh1 "#{verb} #{outdated_casks.count} outdated #{::Utils.pluralize("package", outdated_casks.count)}:"
|
||||||
outdated_casks.count)}:"
|
|
||||||
|
|
||||||
caught_exceptions = []
|
caught_exceptions = []
|
||||||
|
|
||||||
|
@ -584,8 +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 #{Utils.pluralize("formula", formulae_names.count,
|
oh1 "#{verb} #{formulae_names.count} unneeded #{Utils.pluralize("formula", formulae_names.count, plural: "e")}:"
|
||||||
plural: "e")}:"
|
|
||||||
puts formulae_names.join("\n")
|
puts formulae_names.join("\n")
|
||||||
return if dry_run
|
return if dry_run
|
||||||
|
|
||||||
|
@ -684,8 +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} #{Utils.pluralize("argument",
|
"This command does not take more than #{maximum} #{arg_types} #{Utils.pluralize("argument", maximum)}."
|
||||||
maximum)}."
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -699,8 +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} #{Utils.pluralize("argument",
|
super "This command requires at least #{minimum} #{arg_types} #{Utils.pluralize("argument", minimum)}."
|
||||||
minimum)}."
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -713,8 +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} #{Utils.pluralize("argument",
|
super "This command requires exactly #{minimum} #{arg_types} #{Utils.pluralize("argument", minimum)}."
|
||||||
minimum)}."
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -40,8 +40,7 @@ module Homebrew
|
|||||||
case args.named.first
|
case args.named.first
|
||||||
when nil, "state"
|
when nil, "state"
|
||||||
if env_vars.any?
|
if env_vars.any?
|
||||||
verb = Utils.pluralize("", env_vars.count, plural: "are", singular: "is")
|
puts "Developer mode is enabled because #{env_vars.to_sentence} #{env_vars.count == 1 ? "is" : "are"} set."
|
||||||
puts "Developer mode is enabled because #{env_vars.to_sentence} #{verb} set."
|
|
||||||
elsif Homebrew::Settings.read("devcmdrun") == "true"
|
elsif Homebrew::Settings.read("devcmdrun") == "true"
|
||||||
puts "Developer mode is enabled."
|
puts "Developer mode is enabled."
|
||||||
else
|
else
|
||||||
|
@ -199,8 +199,8 @@ module Homebrew
|
|||||||
|
|
||||||
unless updated_taps.empty?
|
unless updated_taps.empty?
|
||||||
auto_update_header args: args
|
auto_update_header args: args
|
||||||
puts "Updated #{updated_taps.count} #{Utils.pluralize("tap",
|
noun = Utils.pluralize("tap", updated_taps.count)
|
||||||
updated_taps.count)} (#{updated_taps.to_sentence})."
|
puts "Updated #{updated_taps.count} #{noun} (#{updated_taps.to_sentence})."
|
||||||
updated = true
|
updated = true
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -585,8 +585,8 @@ class ReporterHub
|
|||||||
output_dump_formula_or_cask_report "Outdated Casks", outdated_casks
|
output_dump_formula_or_cask_report "Outdated Casks", outdated_casks
|
||||||
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",
|
noun = Utils.pluralize("formula", changed_formulae, plural: "e")
|
||||||
"Modified #{changed_formulae} #{Utils.pluralize("formula", changed_formulae, plural: "e")}."
|
ohai "Modified Formulae", "Modified #{changed_formulae} #{noun}."
|
||||||
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?
|
||||||
@ -611,14 +611,13 @@ class ReporterHub
|
|||||||
msg = ""
|
msg = ""
|
||||||
|
|
||||||
if outdated_formulae.positive?
|
if outdated_formulae.positive?
|
||||||
msg += "#{Tty.bold}#{outdated_formulae}#{Tty.reset} outdated #{Utils.pluralize("formula",
|
noun = Utils.pluralize("formula", outdated_formulae, plural: "e")
|
||||||
outdated_formulae, plural: "e")}"
|
msg += "#{Tty.bold}#{outdated_formulae}#{Tty.reset} outdated #{noun}"
|
||||||
end
|
end
|
||||||
|
|
||||||
if outdated_casks.positive?
|
if outdated_casks.positive?
|
||||||
msg += " and " if msg.present?
|
msg += " and " if msg.present?
|
||||||
msg += "#{Tty.bold}#{outdated_casks}#{Tty.reset} outdated #{Utils.pluralize("cask",
|
msg += "#{Tty.bold}#{outdated_casks}#{Tty.reset} outdated #{Utils.pluralize("cask", outdated_casks)}"
|
||||||
outdated_casks)}"
|
|
||||||
end
|
end
|
||||||
|
|
||||||
return if msg.blank?
|
return if msg.blank?
|
||||||
|
@ -180,8 +180,7 @@ module Homebrew
|
|||||||
oh1 "No packages to upgrade"
|
oh1 "No packages to upgrade"
|
||||||
else
|
else
|
||||||
verb = args.dry_run? ? "Would upgrade" : "Upgrading"
|
verb = args.dry_run? ? "Would upgrade" : "Upgrading"
|
||||||
oh1 "#{verb} #{formulae_to_install.count} outdated #{Utils.pluralize("package",
|
oh1 "#{verb} #{formulae_to_install.count} outdated #{Utils.pluralize("package", formulae_to_install.count)}:"
|
||||||
formulae_to_install.count)}:"
|
|
||||||
formulae_upgrades = formulae_to_install.map do |f|
|
formulae_upgrades = formulae_to_install.map do |f|
|
||||||
if f.optlinked?
|
if f.optlinked?
|
||||||
"#{f.full_specified_name} #{Keg.new(f.opt_prefix).version} -> #{f.pkg_version}"
|
"#{f.full_specified_name} #{Keg.new(f.opt_prefix).version} -> #{f.pkg_version}"
|
||||||
|
@ -281,8 +281,7 @@ module Homebrew
|
|||||||
|
|
||||||
error_sources = []
|
error_sources = []
|
||||||
if formula_count.positive?
|
if formula_count.positive?
|
||||||
error_sources << "#{formula_count} #{Utils.pluralize("formula", formula_count,
|
error_sources << "#{formula_count} #{Utils.pluralize("formula", formula_count, plural: "e")}"
|
||||||
plural: "e")}"
|
|
||||||
end
|
end
|
||||||
error_sources << "#{cask_count} #{Utils.pluralize("cask", cask_count)}" if cask_count.positive?
|
error_sources << "#{cask_count} #{Utils.pluralize("cask", cask_count)}" if cask_count.positive?
|
||||||
error_sources << "#{tap_count} #{Utils.pluralize("tap", tap_count)}" if tap_count.positive?
|
error_sources << "#{tap_count} #{Utils.pluralize("tap", tap_count)}" if tap_count.positive?
|
||||||
@ -292,8 +291,8 @@ module Homebrew
|
|||||||
errors_summary += " detected"
|
errors_summary += " detected"
|
||||||
|
|
||||||
if corrected_problem_count.positive?
|
if corrected_problem_count.positive?
|
||||||
errors_summary += ", #{corrected_problem_count} #{Utils.pluralize("problem",
|
noun = Utils.pluralize("problem", corrected_problem_count)
|
||||||
corrected_problem_count)} corrected"
|
errors_summary += ", #{corrected_problem_count} #{noun} corrected"
|
||||||
end
|
end
|
||||||
|
|
||||||
ofail errors_summary
|
ofail errors_summary
|
||||||
|
@ -101,8 +101,7 @@ module Homebrew
|
|||||||
"#{Utils.demodulize(T.must(name))} only supports a regex when using a `strategy` block"
|
"#{Utils.demodulize(T.must(name))} only supports a regex when using a `strategy` block"
|
||||||
end
|
end
|
||||||
unless T.unsafe(cask)
|
unless T.unsafe(cask)
|
||||||
raise ArgumentError,
|
raise ArgumentError, "The #{Utils.demodulize(T.must(name))} strategy only supports casks."
|
||||||
"The #{Utils.demodulize(T.must(name))} strategy only supports casks."
|
|
||||||
end
|
end
|
||||||
|
|
||||||
match_data = { matches: {}, regex: regex, url: url }
|
match_data = { matches: {}, regex: regex, url: url }
|
||||||
|
@ -3415,56 +3415,6 @@ class Regexp::Token < ::Struct
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# class String
|
|
||||||
# include ::Comparable
|
|
||||||
# include ::JSON::Ext::Generator::GeneratorMethods::String
|
|
||||||
# include ::MessagePack::CoreExt
|
|
||||||
# extend ::JSON::Ext::Generator::GeneratorMethods::String::Extend
|
|
||||||
|
|
||||||
# def acts_like_string?; end
|
|
||||||
# def as_json(options = T.unsafe(nil)); end
|
|
||||||
# def at(position); end
|
|
||||||
# def blank?; end
|
|
||||||
# def camelcase(first_letter = T.unsafe(nil)); end
|
|
||||||
# def camelize(first_letter = T.unsafe(nil)); end
|
|
||||||
# def classify; end
|
|
||||||
# def constantize; end
|
|
||||||
# def dasherize; end
|
|
||||||
# def deconstantize; end
|
|
||||||
# def demodulize; end
|
|
||||||
# def first(limit = T.unsafe(nil)); end
|
|
||||||
# def foreign_key(separate_class_name_and_id_with_underscore = T.unsafe(nil)); end
|
|
||||||
# def from(position); end
|
|
||||||
# def html_safe; end
|
|
||||||
# def humanize(capitalize: T.unsafe(nil), keep_id_suffix: T.unsafe(nil)); end
|
|
||||||
# def is_utf8?; end
|
|
||||||
# def last(limit = T.unsafe(nil)); end
|
|
||||||
# def mb_chars; end
|
|
||||||
# def parameterize(separator: T.unsafe(nil), preserve_case: T.unsafe(nil), locale: T.unsafe(nil)); end
|
|
||||||
# def pluralize(count = T.unsafe(nil), locale = T.unsafe(nil)); end
|
|
||||||
# def remove(*patterns); end
|
|
||||||
# def remove!(*patterns); end
|
|
||||||
# def safe_constantize; end
|
|
||||||
# def singularize(locale = T.unsafe(nil)); end
|
|
||||||
# def squish; end
|
|
||||||
# def squish!; end
|
|
||||||
# def tableize; end
|
|
||||||
# def titlecase(keep_id_suffix: T.unsafe(nil)); end
|
|
||||||
# def titleize(keep_id_suffix: T.unsafe(nil)); end
|
|
||||||
# def to(position); end
|
|
||||||
# def to_date; end
|
|
||||||
# def to_datetime; end
|
|
||||||
# def to_time(form = T.unsafe(nil)); end
|
|
||||||
# def truncate(truncate_at, options = T.unsafe(nil)); end
|
|
||||||
# def truncate_bytes(truncate_at, omission: T.unsafe(nil)); end
|
|
||||||
# def truncate_words(words_count, options = T.unsafe(nil)); end
|
|
||||||
# def underscore; end
|
|
||||||
# def upcase_first; end
|
|
||||||
# end
|
|
||||||
|
|
||||||
# String::BLANK_RE = T.let(T.unsafe(nil), Regexp)
|
|
||||||
# String::ENCODED_BLANKS = T.let(T.unsafe(nil), Concurrent::Map)
|
|
||||||
|
|
||||||
class Struct
|
class Struct
|
||||||
include ::Enumerable
|
include ::Enumerable
|
||||||
|
|
||||||
|
@ -52,7 +52,7 @@ module Homebrew
|
|||||||
if rack.directory?
|
if rack.directory?
|
||||||
versions = rack.subdirs.map(&:basename)
|
versions = rack.subdirs.map(&:basename)
|
||||||
puts <<~EOS
|
puts <<~EOS
|
||||||
#{keg.name} #{versions.to_sentence} #{Utils.pluralize("", versions.count, plural: "are", singular: "is")} still installed.
|
#{keg.name} #{versions.to_sentence} #{versions.count == 1 ? "is" : "are"} still installed.
|
||||||
To remove all versions, run:
|
To remove all versions, run:
|
||||||
brew uninstall --force #{keg.name}
|
brew uninstall --force #{keg.name}
|
||||||
EOS
|
EOS
|
||||||
@ -136,9 +136,8 @@ module Homebrew
|
|||||||
end
|
end
|
||||||
|
|
||||||
def are_required_by_deps
|
def are_required_by_deps
|
||||||
"#{Utils.pluralize("", reqs.count, plural: "are",
|
"#{reqs.count == 1 ? "is" : "are"} required by #{deps.to_sentence}, " \
|
||||||
singular: "is")} required by #{deps.to_sentence}, " \
|
"which #{deps.count == 1 ? "is" : "are"} currently installed"
|
||||||
"which #{Utils.pluralize("", deps.count, plural: "are", singular: "is")} currently installed"
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -158,7 +157,7 @@ module Homebrew
|
|||||||
def output
|
def output
|
||||||
ofail <<~EOS
|
ofail <<~EOS
|
||||||
Refusing to uninstall #{reqs.to_sentence}
|
Refusing to uninstall #{reqs.to_sentence}
|
||||||
because #{Utils.pluralize("", reqs.count, plural: "they", singular: "it")} #{are_required_by_deps}.
|
because #{(reqs.count == 1) ? "it" : "they"} #{are_required_by_deps}.
|
||||||
You can override this and force removal with:
|
You can override this and force removal with:
|
||||||
#{sample_command}
|
#{sample_command}
|
||||||
EOS
|
EOS
|
||||||
|
@ -1,52 +0,0 @@
|
|||||||
# typed: strict
|
|
||||||
# frozen_string_literal: true
|
|
||||||
|
|
||||||
module Utils
|
|
||||||
# Inflection utility methods, as a lightweight alternative to `ActiveSupport::Inflector``.
|
|
||||||
#
|
|
||||||
# @api private
|
|
||||||
module Inflection
|
|
||||||
extend T::Sig
|
|
||||||
# Removes the rightmost segment from the constant expression in the string.
|
|
||||||
#
|
|
||||||
# deconstantize('Net::HTTP') # => "Net"
|
|
||||||
# deconstantize('::Net::HTTP') # => "::Net"
|
|
||||||
# deconstantize('String') # => ""
|
|
||||||
# deconstantize('::String') # => ""
|
|
||||||
# deconstantize('') # => ""
|
|
||||||
#
|
|
||||||
# See also #demodulize.
|
|
||||||
# @see https://github.com/rails/rails/blob/b0dd7c7/activesupport/lib/active_support/inflector/methods.rb#L247-L258
|
|
||||||
# `ActiveSupport::Inflector.deconstantize`
|
|
||||||
sig { params(path: String).returns(String) }
|
|
||||||
def self.deconstantize(path)
|
|
||||||
T.must(path[0, path.rindex("::") || 0]) # implementation based on the one in facets' Module#spacename
|
|
||||||
end
|
|
||||||
|
|
||||||
# Removes the module part from the expression in the string.
|
|
||||||
#
|
|
||||||
# demodulize('ActiveSupport::Inflector::Inflections') # => "Inflections"
|
|
||||||
# demodulize('Inflections') # => "Inflections"
|
|
||||||
# demodulize('::Inflections') # => "Inflections"
|
|
||||||
# demodulize('') # => ""
|
|
||||||
#
|
|
||||||
# See also #deconstantize.
|
|
||||||
# @see https://github.com/rails/rails/blob/b0dd7c7/activesupport/lib/active_support/inflector/methods.rb#L230-L245
|
|
||||||
# `ActiveSupport::Inflector.demodulize`
|
|
||||||
sig { params(path: String).returns(String) }
|
|
||||||
def self.demodulize(path)
|
|
||||||
if (i = path.rindex("::"))
|
|
||||||
T.must(path[(i + 2)..])
|
|
||||||
else
|
|
||||||
path
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
# Combines `stem` with the `singular` or `plural` suffix based on `count`.
|
|
||||||
sig { params(stem: String, count: Integer, plural: String, singular: String).returns(String) }
|
|
||||||
def self.pluralize(stem, count, plural: "s", singular: "")
|
|
||||||
suffix = (count == 1) ? singular : plural
|
|
||||||
"#{stem}#{suffix}"
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
Loading…
x
Reference in New Issue
Block a user