Merge pull request #10125 from reitermarkus/sparkle
Fix `Sparkle` strategy.
This commit is contained in:
commit
d535fe3030
@ -10,6 +10,8 @@ module Homebrew
|
|||||||
#
|
#
|
||||||
# @api private
|
# @api private
|
||||||
module Strategy
|
module Strategy
|
||||||
|
extend T::Sig
|
||||||
|
|
||||||
module_function
|
module_function
|
||||||
|
|
||||||
# Strategy priorities informally range from 1 to 10, where 10 is the
|
# Strategy priorities informally range from 1 to 10, where 10 is the
|
||||||
@ -120,6 +122,7 @@ module Homebrew
|
|||||||
#
|
#
|
||||||
# @param url [String] the URL of the content to check
|
# @param url [String] the URL of the content to check
|
||||||
# @return [Hash]
|
# @return [Hash]
|
||||||
|
sig { params(url: String).returns(T::Hash[Symbol, T.untyped]) }
|
||||||
def self.page_content(url)
|
def self.page_content(url)
|
||||||
original_url = url
|
original_url = url
|
||||||
|
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
# typed: false
|
# typed: true
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
require "open-uri"
|
require "open-uri"
|
||||||
@ -19,6 +19,8 @@ module Homebrew
|
|||||||
#
|
#
|
||||||
# @api public
|
# @api public
|
||||||
class PageMatch
|
class PageMatch
|
||||||
|
extend T::Sig
|
||||||
|
|
||||||
NICE_NAME = "Page match"
|
NICE_NAME = "Page match"
|
||||||
|
|
||||||
# A priority of zero causes livecheck to skip the strategy. We do this
|
# A priority of zero causes livecheck to skip the strategy. We do this
|
||||||
@ -32,9 +34,7 @@ module Homebrew
|
|||||||
# Whether the strategy can be applied to the provided URL.
|
# Whether the strategy can be applied to the provided URL.
|
||||||
# PageMatch will technically match any HTTP URL but is only
|
# PageMatch will technically match any HTTP URL but is only
|
||||||
# usable with a `livecheck` block containing a regex.
|
# usable with a `livecheck` block containing a regex.
|
||||||
#
|
sig { params(url: String).returns(T::Boolean) }
|
||||||
# @param url [String] the URL to match against
|
|
||||||
# @return [Boolean]
|
|
||||||
def self.match?(url)
|
def self.match?(url)
|
||||||
URL_MATCH_REGEX.match?(url)
|
URL_MATCH_REGEX.match?(url)
|
||||||
end
|
end
|
||||||
@ -71,10 +71,7 @@ module Homebrew
|
|||||||
|
|
||||||
# Checks the content at the URL for new versions, using the provided
|
# Checks the content at the URL for new versions, using the provided
|
||||||
# regex for matching.
|
# regex for matching.
|
||||||
#
|
sig { params(url: String, regex: T.nilable(Regexp)).returns(T::Hash[Symbol, T.untyped]) }
|
||||||
# @param url [String] the URL of the content to check
|
|
||||||
# @param regex [Regexp] a regex used for matching versions in content
|
|
||||||
# @return [Hash]
|
|
||||||
def self.find_versions(url, regex, &block)
|
def self.find_versions(url, regex, &block)
|
||||||
match_data = { matches: {}, regex: regex, url: url }
|
match_data = { matches: {}, regex: regex, url: url }
|
||||||
|
|
||||||
|
|||||||
@ -89,7 +89,8 @@ module Homebrew
|
|||||||
|
|
||||||
match_data = { matches: {}, regex: regex, url: url }
|
match_data = { matches: {}, regex: regex, url: url }
|
||||||
|
|
||||||
content = Strategy.page_content(url)
|
match_data.merge!(Strategy.page_content(url))
|
||||||
|
content = match_data.delete(:content)
|
||||||
|
|
||||||
if (item = item_from_content(content))
|
if (item = item_from_content(content))
|
||||||
match = if block
|
match = if block
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user