mirror of
https://github.com/Homebrew/brew.git
synced 2025-07-14 16:09:03 +08:00
Add additional method signatures to strategies
This commit is contained in:
parent
7e07010f06
commit
f2bd39ccef
@ -86,6 +86,7 @@ module Homebrew
|
||||
# At present, this should only be called after tap strategies have been
|
||||
# loaded, otherwise livecheck won't be able to use them.
|
||||
# @return [Hash]
|
||||
sig { returns(T::Hash[Symbol, T.untyped]) }
|
||||
def strategies
|
||||
return @strategies if defined? @strategies
|
||||
|
||||
@ -107,8 +108,9 @@ module Homebrew
|
||||
# @param symbol [Symbol] the strategy name in snake case as a `Symbol`
|
||||
# (e.g. `:page_match`)
|
||||
# @return [Strategy, nil]
|
||||
sig { params(symbol: T.nilable(Symbol)).returns(T.nilable(T.untyped)) }
|
||||
def from_symbol(symbol)
|
||||
strategies[symbol]
|
||||
strategies[symbol] if symbol.present?
|
||||
end
|
||||
|
||||
# Returns an array of strategies that apply to the provided URL.
|
||||
@ -119,7 +121,16 @@ module Homebrew
|
||||
# @param regex_provided [Boolean] whether a regex is provided in the
|
||||
# `livecheck` block
|
||||
# @return [Array]
|
||||
def from_url(url, livecheck_strategy: nil, url_provided: nil, regex_provided: nil, block_provided: nil)
|
||||
sig {
|
||||
params(
|
||||
url: String,
|
||||
livecheck_strategy: T.nilable(Symbol),
|
||||
url_provided: T::Boolean,
|
||||
regex_provided: T::Boolean,
|
||||
block_provided: T::Boolean,
|
||||
).returns(T::Array[T.untyped])
|
||||
}
|
||||
def from_url(url, livecheck_strategy: nil, url_provided: false, regex_provided: false, block_provided: false)
|
||||
usable_strategies = strategies.values.select do |strategy|
|
||||
if strategy == PageMatch
|
||||
# Only treat the `PageMatch` strategy as usable if a regex is
|
||||
@ -143,6 +154,7 @@ module Homebrew
|
||||
end
|
||||
end
|
||||
|
||||
sig { params(url: String).returns(T::Array[T::Hash[String, String]]) }
|
||||
def self.page_headers(url)
|
||||
headers = []
|
||||
|
||||
|
@ -37,6 +37,7 @@ module Homebrew
|
||||
#
|
||||
# @param url [String] the URL to match against
|
||||
# @return [Boolean]
|
||||
sig { params(url: String).returns(T::Boolean) }
|
||||
def self.match?(url)
|
||||
URL_MATCH_REGEX.match?(url)
|
||||
end
|
||||
|
@ -44,6 +44,7 @@ module Homebrew
|
||||
#
|
||||
# @param url [String] the URL to match against
|
||||
# @return [Boolean]
|
||||
sig { params(url: String).returns(T::Boolean) }
|
||||
def self.match?(url)
|
||||
URL_MATCH_REGEX.match?(url)
|
||||
end
|
||||
|
@ -35,6 +35,7 @@ module Homebrew
|
||||
#
|
||||
# @param url [String] the URL to match against
|
||||
# @return [Boolean]
|
||||
sig { params(url: String).returns(T::Boolean) }
|
||||
def self.match?(url)
|
||||
URL_MATCH_REGEX.match?(url)
|
||||
end
|
||||
|
@ -50,6 +50,7 @@ module Homebrew
|
||||
# @param url [String] the URL of the Git repository to check
|
||||
# @param regex [Regexp] the regex to use for filtering tags
|
||||
# @return [Hash]
|
||||
sig { params(url: String, regex: T.nilable(Regexp)).returns(T::Hash[Symbol, T.untyped]) }
|
||||
def self.tag_info(url, regex = nil)
|
||||
# Open3#capture3 is used here because we need to capture stderr
|
||||
# output and handle it in an appropriate manner. Alternatives like
|
||||
|
@ -52,6 +52,7 @@ module Homebrew
|
||||
#
|
||||
# @param url [String] the URL to match against
|
||||
# @return [Boolean]
|
||||
sig { params(url: String).returns(T::Boolean) }
|
||||
def self.match?(url)
|
||||
URL_MATCH_REGEX.match?(url)
|
||||
end
|
||||
|
@ -40,6 +40,7 @@ module Homebrew
|
||||
#
|
||||
# @param url [String] the URL to match against
|
||||
# @return [Boolean]
|
||||
sig { params(url: String).returns(T::Boolean) }
|
||||
def self.match?(url)
|
||||
URL_MATCH_REGEX.match?(url)
|
||||
end
|
||||
|
@ -44,6 +44,7 @@ module Homebrew
|
||||
#
|
||||
# @param url [String] the URL to match against
|
||||
# @return [Boolean]
|
||||
sig { params(url: String).returns(T::Boolean) }
|
||||
def self.match?(url)
|
||||
URL_MATCH_REGEX.match?(url) && url.exclude?("savannah.")
|
||||
end
|
||||
|
@ -37,6 +37,7 @@ module Homebrew
|
||||
#
|
||||
# @param url [String] the URL to match against
|
||||
# @return [Boolean]
|
||||
sig { params(url: String).returns(T::Boolean) }
|
||||
def self.match?(url)
|
||||
URL_MATCH_REGEX.match?(url)
|
||||
end
|
||||
|
@ -35,6 +35,7 @@ module Homebrew
|
||||
#
|
||||
# @param url [String] the URL to match against
|
||||
# @return [Boolean]
|
||||
sig { params(url: String).returns(T::Boolean) }
|
||||
def self.match?(url)
|
||||
URL_MATCH_REGEX.match?(url)
|
||||
end
|
||||
|
@ -31,6 +31,7 @@ module Homebrew
|
||||
#
|
||||
# @param url [String] the URL to match against
|
||||
# @return [Boolean]
|
||||
sig { params(url: String).returns(T::Boolean) }
|
||||
def self.match?(url)
|
||||
URL_MATCH_REGEX.match?(url)
|
||||
end
|
||||
|
@ -41,6 +41,7 @@ module Homebrew
|
||||
#
|
||||
# @param url [String] the URL to match against
|
||||
# @return [Boolean]
|
||||
sig { params(url: String).returns(T::Boolean) }
|
||||
def self.match?(url)
|
||||
URL_MATCH_REGEX.match?(url)
|
||||
end
|
||||
|
@ -47,6 +47,7 @@ module Homebrew
|
||||
#
|
||||
# @param url [String] the URL to match against
|
||||
# @return [Boolean]
|
||||
sig { params(url: String).returns(T::Boolean) }
|
||||
def self.match?(url)
|
||||
URL_MATCH_REGEX.match?(url)
|
||||
end
|
||||
|
@ -64,6 +64,7 @@ module Homebrew
|
||||
#
|
||||
# @param url [String] the URL to match against
|
||||
# @return [Boolean]
|
||||
sig { params(url: String).returns(T::Boolean) }
|
||||
def self.match?(url)
|
||||
URL_MATCH_REGEX.match?(url)
|
||||
end
|
||||
|
Loading…
x
Reference in New Issue
Block a user