From 590aabe9d7d8d383c2be013e16e5fdf83942d584 Mon Sep 17 00:00:00 2001 From: Sam Ford <1584702+samford@users.noreply.github.com> Date: Thu, 9 Jun 2022 15:33:42 -0400 Subject: [PATCH 1/2] livecheck: update default match_data This updates these strategies to better align with the default `match_data` value in other strategies. --- Library/Homebrew/livecheck/strategy/electron_builder.rb | 2 +- Library/Homebrew/livecheck/strategy/extract_plist.rb | 2 +- Library/Homebrew/livecheck/strategy/sparkle.rb | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Library/Homebrew/livecheck/strategy/electron_builder.rb b/Library/Homebrew/livecheck/strategy/electron_builder.rb index f33f692052..4b8bdc3273 100644 --- a/Library/Homebrew/livecheck/strategy/electron_builder.rb +++ b/Library/Homebrew/livecheck/strategy/electron_builder.rb @@ -75,7 +75,7 @@ module Homebrew raise ArgumentError, "#{T.must(name).demodulize} only supports a regex when using a `strategy` block" end - match_data = { matches: {}, url: url } + match_data = { matches: {}, regex: regex, url: url } match_data.merge!(Strategy.page_content(url)) content = match_data.delete(:content) diff --git a/Library/Homebrew/livecheck/strategy/extract_plist.rb b/Library/Homebrew/livecheck/strategy/extract_plist.rb index 580d634727..a1593fb840 100644 --- a/Library/Homebrew/livecheck/strategy/extract_plist.rb +++ b/Library/Homebrew/livecheck/strategy/extract_plist.rb @@ -96,7 +96,7 @@ module Homebrew end raise ArgumentError, "The #{T.must(name).demodulize} strategy only supports casks." unless T.unsafe(cask) - match_data = { matches: {} } + match_data = { matches: {}, regex: regex } unversioned_cask_checker = UnversionedCaskChecker.new(cask) items = unversioned_cask_checker.all_versions.transform_values { |v| Item.new(bundle_version: v) } diff --git a/Library/Homebrew/livecheck/strategy/sparkle.rb b/Library/Homebrew/livecheck/strategy/sparkle.rb index f599020f51..26df689d4d 100644 --- a/Library/Homebrew/livecheck/strategy/sparkle.rb +++ b/Library/Homebrew/livecheck/strategy/sparkle.rb @@ -199,7 +199,7 @@ module Homebrew raise ArgumentError, "#{T.must(name).demodulize} only supports a regex when using a `strategy` block" end - match_data = { matches: {}, url: url } + match_data = { matches: {}, regex: regex, url: url } match_data.merge!(Strategy.page_content(url)) content = match_data.delete(:content) From d600b662e255291232efa10c38d973697eea2dde Mon Sep 17 00:00:00 2001 From: Sam Ford <1584702+samford@users.noreply.github.com> Date: Thu, 9 Jun 2022 15:38:02 -0400 Subject: [PATCH 2/2] Expand documentation comments --- .../livecheck/strategy/electron_builder.rb | 5 +++-- .../livecheck/strategy/extract_plist.rb | 2 ++ Library/Homebrew/livecheck/strategy/sparkle.rb | 17 ++++++++++++----- 3 files changed, 17 insertions(+), 7 deletions(-) diff --git a/Library/Homebrew/livecheck/strategy/electron_builder.rb b/Library/Homebrew/livecheck/strategy/electron_builder.rb index 4b8bdc3273..3d0a4c7437 100644 --- a/Library/Homebrew/livecheck/strategy/electron_builder.rb +++ b/Library/Homebrew/livecheck/strategy/electron_builder.rb @@ -4,8 +4,8 @@ module Homebrew module Livecheck module Strategy - # The {ElectronBuilder} strategy fetches content at a URL and parses - # it as an electron-builder appcast in YAML format. + # The {ElectronBuilder} strategy fetches content at a URL and parses it + # as an electron-builder appcast in YAML format. # # This strategy is not applied automatically and it's necessary to use # `strategy :electron_builder` in a `livecheck` block to apply it. @@ -35,6 +35,7 @@ module Homebrew # Parses YAML text and identifies versions in it. # # @param content [String] the YAML text to parse and check + # @param regex [Regexp, nil] a regex for use in a strategy block # @return [Array] sig { params( diff --git a/Library/Homebrew/livecheck/strategy/extract_plist.rb b/Library/Homebrew/livecheck/strategy/extract_plist.rb index a1593fb840..0bf114f63d 100644 --- a/Library/Homebrew/livecheck/strategy/extract_plist.rb +++ b/Library/Homebrew/livecheck/strategy/extract_plist.rb @@ -58,6 +58,7 @@ module Homebrew # {UnversionedCaskChecker} version information. # # @param items [Hash] a hash of `Item`s containing version information + # @param regex [Regexp, nil] a regex for use in a strategy block # @return [Array] sig { params( @@ -81,6 +82,7 @@ module Homebrew # versions from `plist` files. # # @param cask [Cask::Cask] the cask to check for version information + # @param regex [Regexp, nil] a regex for use in a strategy block # @return [Hash] sig { params( diff --git a/Library/Homebrew/livecheck/strategy/sparkle.rb b/Library/Homebrew/livecheck/strategy/sparkle.rb index 26df689d4d..bddb6bc8ef 100644 --- a/Library/Homebrew/livecheck/strategy/sparkle.rb +++ b/Library/Homebrew/livecheck/strategy/sparkle.rb @@ -6,8 +6,8 @@ require "bundle_version" module Homebrew module Livecheck module Strategy - # The {Sparkle} strategy fetches content at a URL and parses - # it as a Sparkle appcast in XML format. + # The {Sparkle} strategy fetches content at a URL and parses it as a + # Sparkle appcast in XML format. # # This strategy is not applied automatically and it's necessary to use # `strategy :sparkle` in a `livecheck` block to apply it. @@ -60,7 +60,7 @@ module Homebrew delegate nice_version: :bundle_version end - # Identify version information from a Sparkle appcast. + # Identifies version information from a Sparkle appcast. # # @param content [String] the text of the Sparkle appcast # @return [Item, nil] @@ -152,9 +152,12 @@ module Homebrew end.compact end - # Identify versions from content + # Uses `#items_from_content` to identify versions from the Sparkle + # appcast content or, if a block is provided, passes the content to + # the block to handle matching. # - # @param content [String] the content to pull version information from + # @param content [String] the content to check + # @param regex [Regexp, nil] a regex for use in a strategy block # @return [Array] sig { params( @@ -186,6 +189,10 @@ module Homebrew end # Checks the content at the URL for new versions. + # + # @param url [String] the URL of the content to check + # @param regex [Regexp, nil] a regex for use in a strategy block + # @return [Hash] sig { params( url: String,