Fix Sparkle strategy.

This commit is contained in:
Markus Reiter 2020-12-24 03:33:14 +01:00
parent a8faeef64d
commit bf7efb369c
3 changed files with 10 additions and 9 deletions

View File

@ -10,6 +10,8 @@ module Homebrew
#
# @api private
module Strategy
extend T::Sig
module_function
# 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
# @return [Hash]
sig { params(url: String).returns(T::Hash[Symbol, T.untyped]) }
def self.page_content(url)
original_url = url

View File

@ -1,4 +1,4 @@
# typed: false
# typed: true
# frozen_string_literal: true
require "open-uri"
@ -19,6 +19,8 @@ module Homebrew
#
# @api public
class PageMatch
extend T::Sig
NICE_NAME = "Page match"
# 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.
# PageMatch will technically match any HTTP URL but is only
# usable with a `livecheck` block containing a regex.
#
# @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
@ -71,10 +71,7 @@ module Homebrew
# Checks the content at the URL for new versions, using the provided
# regex for matching.
#
# @param url [String] the URL of the content to check
# @param regex [Regexp] a regex used for matching versions in content
# @return [Hash]
sig { params(url: String, regex: T.nilable(Regexp)).returns(T::Hash[Symbol, T.untyped]) }
def self.find_versions(url, regex, &block)
match_data = { matches: {}, regex: regex, url: url }

View File

@ -89,7 +89,8 @@ module Homebrew
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))
match = if block