Exception: FormulaOrCaskUnavailableError Private
- Defined in:
- exceptions.rb
Overview
This class is part of a private API. This class may only be used in the Homebrew/brew repository. Third parties should avoid using this class if possible, as it may be removed or changed without warning.
Raised when neither a formula nor a cask with the given name is available.
Direct Known Subclasses
Instance Attribute Summary collapse
- #name ⇒ String readonly private
Instance Method Summary collapse
- #did_you_mean ⇒ String private
- #initialize(name) ⇒ void constructor private
Constructor Details
#initialize(name) ⇒ 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.
123 124 125 126 127 128 129 130 131 132 133 |
# File 'exceptions.rb', line 123 def initialize(name) super() @name = name # Store the state of these envs at the time the exception is thrown. # This is so we do the fuzzy search for "did you mean" etc under that same mode, # in case the list of formulae are different. @without_api = T.let(Homebrew::EnvConfig.no_install_from_api?, T::Boolean) @auto_without_api = T.let(Homebrew::EnvConfig.automatically_set_no_install_from_api?, T::Boolean) end |
Instance Attribute Details
#name ⇒ 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.
120 121 122 |
# File 'exceptions.rb', line 120 def name @name end |
Instance Method Details
#did_you_mean ⇒ 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.
136 137 138 139 140 141 142 143 |
# File 'exceptions.rb', line 136 def did_you_mean require "formula" similar_formula_names = Homebrew.with_no_api_env_if_needed(@without_api) { Formula.fuzzy_search(name) } return "" if similar_formula_names.blank? "Did you mean #{similar_formula_names.to_sentence two_words_connector: " or ", last_word_connector: " or "}?" end |