Class: DependentsMessage

Inherits:
Object show all
Includes:
Utils::Output::Mixin
Defined in:
dependents_message.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Utils::Output::Mixin

#issue_reporting_message, #odebug, #odeprecated, #odie, #odisabled, #ofail, #oh1, #oh1_title, #ohai, #ohai_title, #onoe, #opoo, #opoo_once, #opoo_outside_github_actions, #opoo_without_github_actions_annotation, #pretty_cannot_install, #pretty_deprecated, #pretty_disabled, #pretty_duration, #pretty_incompatible, #pretty_install_status, #pretty_installed, #pretty_removed, #pretty_uninstalled, #pretty_unmarked, #pretty_upgradable, #pretty_warning

Constructor Details

#initialize(requireds, dependents, named_args: [], build: false, commands: []) ⇒ void

This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.

Parameters:



21
22
23
24
25
26
27
# File 'dependents_message.rb', line 21

def initialize(requireds, dependents, named_args: [], build: false, commands: [])
  @reqs = requireds
  @deps = dependents
  @named_args = named_args
  @build = build
  @commands = commands
end

Instance Attribute Details

#deps ⇒ Array<String> (readonly)

This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.

Returns:



15
16
17
# File 'dependents_message.rb', line 15

def deps
  @deps
end

#named_args ⇒ Array<String> (readonly)

This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.

Returns:



15
16
17
# File 'dependents_message.rb', line 15

def named_args
  @named_args
end

#reqs ⇒ Array<String, Keg> (readonly)

This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.

Returns:



12
13
14
# File 'dependents_message.rb', line 12

def reqs
  @reqs
end

Instance Method Details

#output ⇒ void

This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.

This method returns an undefined value.



30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'dependents_message.rb', line 30

def output
  verb = deps.one? ? "is" : "are"
  installed_deps = "#{Utils::Text.to_sentence(deps)}, which #{verb} currently installed"
  it_is_or_they_are = reqs.one? ? "it is" : "they are"
  to_build_or_by = @build ? "to build" : "by"
  it_or_them = reqs.one? ? "it" : "them"
  commands = @commands.map { |command| "  #{command}\n" }.join
  hint = "To stop the dependents below from requiring #{it_or_them}, run:\n#{commands}" if commands.present?
  ofail <<~EOS
    Refusing to uninstall #{Utils::Text.to_sentence(reqs)}
    because #{it_is_or_they_are} required #{to_build_or_by} #{installed_deps}.
    #{hint}You can override this and force removal with:
      brew uninstall --ignore-dependencies #{named_args.join(" ")}
  EOS
end