From bf7efb369c47afd979dbd66b84a2417c5e0b8fe2 Mon Sep 17 00:00:00 2001 From: Markus Reiter Date: Thu, 24 Dec 2020 03:33:14 +0100 Subject: [PATCH] Fix `Sparkle` strategy. --- Library/Homebrew/livecheck/strategy.rb | 3 +++ Library/Homebrew/livecheck/strategy/page_match.rb | 13 +++++-------- Library/Homebrew/livecheck/strategy/sparkle.rb | 3 ++- 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/Library/Homebrew/livecheck/strategy.rb b/Library/Homebrew/livecheck/strategy.rb index c08dcdd9c0..832b753da4 100644 --- a/Library/Homebrew/livecheck/strategy.rb +++ b/Library/Homebrew/livecheck/strategy.rb @@ -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 diff --git a/Library/Homebrew/livecheck/strategy/page_match.rb b/Library/Homebrew/livecheck/strategy/page_match.rb index 2b24882299..ac910a7ff8 100644 --- a/Library/Homebrew/livecheck/strategy/page_match.rb +++ b/Library/Homebrew/livecheck/strategy/page_match.rb @@ -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 } diff --git a/Library/Homebrew/livecheck/strategy/sparkle.rb b/Library/Homebrew/livecheck/strategy/sparkle.rb index 63d61a9a9e..62f9824d7e 100644 --- a/Library/Homebrew/livecheck/strategy/sparkle.rb +++ b/Library/Homebrew/livecheck/strategy/sparkle.rb @@ -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