Module: OS::Mac::MissingFormula::ClassMethods Private

Defined in:
extend/os/mac/missing_formula.rb

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

Instance Method Summary collapse

Instance Method Details

#cask_reason(name, silent: false, show_info: false) ⇒ String?

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:

  • name (String)
  • silent (Boolean) (defaults to: false)
  • show_info (Boolean) (defaults to: false)

Returns:



25
26
27
28
29
# File 'extend/os/mac/missing_formula.rb', line 25

def cask_reason(name, silent: false, show_info: false)
  return if silent

  suggest_command(name, show_info ? "info" : "install")
end

#disallowed_reason(name) ⇒ String?

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:

Returns:



13
14
15
16
17
18
19
20
21
22
# File 'extend/os/mac/missing_formula.rb', line 13

def disallowed_reason(name)
  case name.downcase
  when "xcode"
    <<~EOS
      Xcode can be installed from the App Store.
    EOS
  else
    super
  end
end

#suggest_command(name, command) ⇒ String?

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:

Returns:



32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# File 'extend/os/mac/missing_formula.rb', line 32

def suggest_command(name, command)
  suggestion = <<~EOS
    Found a cask named "#{name}" instead. Try
      brew #{command} --cask #{name}

  EOS
  case command
  when "install"
    ::Cask::CaskLoader.load(name)
  when "uninstall"
    cask = ::Cask::Caskroom.casks.find { |installed_cask| installed_cask.to_s == name }
    Kernel.raise ::Cask::CaskUnavailableError, name if cask.nil?
  when "info"
    cask = ::Cask::CaskLoader.load(name)
    suggestion = <<~EOS
      Found a cask named "#{name}" instead.

      #{::Cask::Info.get_info(cask)}
    EOS
  else
    return
  end
  suggestion
rescue ::Cask::CaskUnavailableError
  nil
end