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 ⇒ Object readonly private
Instance Method Summary collapse
- #did_you_mean ⇒ String private
-
#initialize(name) ⇒ FormulaOrCaskUnavailableError
constructor
private
A new instance of FormulaOrCaskUnavailableError.
Constructor Details
#initialize(name) ⇒ FormulaOrCaskUnavailableError
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 a new instance of FormulaOrCaskUnavailableError.
89 90 91 92 93 94 95 96 97 98 99 |
# File 'exceptions.rb', line 89 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 = Homebrew::EnvConfig.no_install_from_api? @auto_without_api = Homebrew::EnvConfig.automatically_set_no_install_from_api? end |
Instance Attribute Details
#name ⇒ Object (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.
87 88 89 |
# File 'exceptions.rb', line 87 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.
102 103 104 105 106 107 108 109 |
# File 'exceptions.rb', line 102 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 |