Class: Livecheck Private
- Extended by:
- Forwardable
- Defined in:
- livecheck.rb,
sorbet/rbi/dsl/livecheck.rbi
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.
The Livecheck class implements the DSL methods used in a formula's, cask's
or resource's livecheck
block and stores related instance variables. Most
of these methods also return the related instance variable when no argument
is provided.
This information is used by the brew livecheck
command to control its
behavior. Example livecheck
blocks can be found in the
brew livecheck
documentation.
Instance Attribute Summary collapse
-
#options ⇒ Homebrew::Livecheck::Options
readonly
private
Options to modify livecheck's behavior.
-
#skip_msg ⇒ String?
readonly
private
A very brief description of why the formula/cask/resource is skipped (e.g.
No longer developed or maintained
). -
#strategy_block ⇒ Proc?
readonly
private
A block used by strategies to identify version information.
Instance Method Summary collapse
-
#cask(cask_name = T.unsafe(nil)) ⇒ String?
private
Sets the
@referenced_cask_name
instance variable to the providedString
or returns the@referenced_cask_name
instance variable when no argument is provided. -
#formula(formula_name = T.unsafe(nil)) ⇒ String, ...
private
Sets the
@referenced_formula_name
instance variable to the providedString
/Symbol
or returns the@referenced_formula_name
instance variable when no argument is provided. - #initialize(package_or_resource) ⇒ void constructor private
-
#regex(pattern = T.unsafe(nil)) ⇒ Regexp?
private
Sets the
@regex
instance variable to the providedRegexp
or returns the@regex
instance variable when no argument is provided. -
#skip(skip_msg = T.unsafe(nil)) ⇒ Boolean
private
Sets the
@skip
instance variable totrue
and sets the@skip_msg
instance variable if aString
is provided. -
#skip? ⇒ Boolean
private
Should
livecheck
skip this formula/cask/resource?. -
#strategy(symbol = T.unsafe(nil), &block) ⇒ Symbol?
private
Sets the
@strategy
instance variable to the providedSymbol
or returns the@strategy
instance variable when no argument is provided. -
#throttle(rate = T.unsafe(nil)) ⇒ Integer?
private
Sets the
@throttle
instance variable to the providedInteger
or returns the@throttle
instance variable when no argument is provided. -
#to_hash ⇒ Hash{String => T.untyped}
private
Returns a
Hash
of all instance variable values. -
#url(url = T.unsafe(nil), homebrew_curl: nil, post_form: nil, post_json: nil) ⇒ String, ...
private
Sets the
@url
instance variable to the provided argument or returns the@url
instance variable when no argument is provided. - #url_options(*args, &block) ⇒ T.untyped private
Constructor Details
#initialize(package_or_resource) ⇒ 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.
33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'livecheck.rb', line 33 def initialize(package_or_resource) @package_or_resource = package_or_resource @options = T.let(Homebrew::Livecheck::Options.new, Homebrew::Livecheck::Options) @referenced_cask_name = T.let(nil, T.nilable(String)) @referenced_formula_name = T.let(nil, T.nilable(String)) @regex = T.let(nil, T.nilable(Regexp)) @skip = T.let(false, T::Boolean) @skip_msg = T.let(nil, T.nilable(String)) @strategy = T.let(nil, T.nilable(Symbol)) @strategy_block = T.let(nil, T.nilable(Proc)) @throttle = T.let(nil, T.nilable(Integer)) @url = T.let(nil, T.any(NilClass, String, Symbol)) end |
Instance Attribute Details
#options ⇒ Homebrew::Livecheck::Options (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.
Options to modify livecheck's behavior.
21 22 23 |
# File 'livecheck.rb', line 21 def @options end |
#skip_msg ⇒ 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.
A very brief description of why the formula/cask/resource is skipped (e.g.
No longer developed or maintained
).
26 27 28 |
# File 'livecheck.rb', line 26 def skip_msg @skip_msg end |
#strategy_block ⇒ Proc? (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.
A block used by strategies to identify version information.
30 31 32 |
# File 'livecheck.rb', line 30 def strategy_block @strategy_block end |
Instance Method Details
#cask(cask_name = T.unsafe(nil)) ⇒ 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.
Sets the @referenced_cask_name
instance variable to the provided String
or returns the @referenced_cask_name
instance variable when no argument
is provided. Inherited livecheck values from the referenced cask
(e.g. regex) can be overridden in the livecheck
block.
57 58 59 60 61 62 63 64 |
# File 'livecheck.rb', line 57 def cask(cask_name = T.unsafe(nil)) case cask_name when nil @referenced_cask_name when String @referenced_cask_name = cask_name end end |
#formula(formula_name = T.unsafe(nil)) ⇒ 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.
Sets the @referenced_formula_name
instance variable to the provided
String
/Symbol
or returns the @referenced_formula_name
instance
variable when no argument is provided. Inherited livecheck values from the
referenced formula (e.g. regex) can be overridden in the livecheck
block.
76 77 78 79 80 81 82 83 |
# File 'livecheck.rb', line 76 def formula(formula_name = T.unsafe(nil)) case formula_name when nil @referenced_formula_name when String, :parent @referenced_formula_name = formula_name end end |
#regex(pattern = T.unsafe(nil)) ⇒ Regexp?
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.
Sets the @regex
instance variable to the provided Regexp
or returns the
@regex
instance variable when no argument is provided.
93 94 95 96 97 98 99 100 |
# File 'livecheck.rb', line 93 def regex(pattern = T.unsafe(nil)) case pattern when nil @regex when Regexp @regex = pattern end end |
#skip(skip_msg = T.unsafe(nil)) ⇒ Boolean
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.
Sets the @skip
instance variable to true
and sets the @skip_msg
instance variable if a String
is provided. @skip
is used to indicate
that the formula/cask/resource should be skipped and the skip_msg
very
briefly describes why it is skipped (e.g. "No longer developed or
maintained").
113 114 115 116 117 |
# File 'livecheck.rb', line 113 def skip(skip_msg = T.unsafe(nil)) @skip_msg = skip_msg if skip_msg.is_a?(String) @skip = true end |
#skip? ⇒ Boolean
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.
Should livecheck
skip this formula/cask/resource?
121 122 123 |
# File 'livecheck.rb', line 121 def skip? @skip end |
#strategy(symbol = T.unsafe(nil), &block) ⇒ Symbol?
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.
Sets the @strategy
instance variable to the provided Symbol
or returns
the @strategy
instance variable when no argument is provided. The strategy
symbols use snake case (e.g. :page_match
) and correspond to the strategy
file name.
136 137 138 139 140 141 142 143 144 145 |
# File 'livecheck.rb', line 136 def strategy(symbol = T.unsafe(nil), &block) @strategy_block = block if block case symbol when nil @strategy when Symbol @strategy = symbol end end |
#throttle(rate = T.unsafe(nil)) ⇒ Integer?
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.
Sets the @throttle
instance variable to the provided Integer
or returns
the @throttle
instance variable when no argument is provided.
155 156 157 158 159 160 161 162 |
# File 'livecheck.rb', line 155 def throttle(rate = T.unsafe(nil)) case rate when nil @throttle when Integer @throttle = rate end end |
#to_hash ⇒ Hash{String => T.untyped}
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 Hash
of all instance variable values.
203 204 205 206 207 208 209 210 211 212 213 214 215 |
# File 'livecheck.rb', line 203 def to_hash { "options" => @options.to_hash, "cask" => @referenced_cask_name, "formula" => @referenced_formula_name, "regex" => @regex, "skip" => @skip, "skip_msg" => @skip_msg, "strategy" => @strategy, "throttle" => @throttle, "url" => @url, } end |
#url(url = T.unsafe(nil), homebrew_curl: nil, post_form: nil, post_json: nil) ⇒ 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.
Sets the @url
instance variable to the provided argument or returns the
@url
instance variable when no argument is provided. The argument can be
a String
(a URL) or a supported Symbol
corresponding to a URL in the
formula/cask/resource (e.g. :stable
, :homepage
, :head
, :url
).
Any options provided to the method are passed through to Strategy
methods
(page_headers
, page_content
).
179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 |
# File 'livecheck.rb', line 179 def url(url = T.unsafe(nil), homebrew_curl: nil, post_form: nil, post_json: nil) raise ArgumentError, "Only use `post_form` or `post_json`, not both" if post_form && post_json @options.homebrew_curl = homebrew_curl unless homebrew_curl.nil? @options.post_form = post_form unless post_form.nil? @options.post_json = post_json unless post_json.nil? case url when nil @url when String, :head, :homepage, :stable, :url @url = url when Symbol raise ArgumentError, "#{url.inspect} is not a valid URL shorthand" end end |
#url_options(*args, &block) ⇒ T.untyped
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.
10 |
# File 'sorbet/rbi/dsl/livecheck.rbi', line 10 def (*args, &block); end |