From 3aa5395f75acb52cc5ae752a70080a19fbd37af6 Mon Sep 17 00:00:00 2001 From: Markus Reiter Date: Mon, 14 Dec 2020 11:34:27 +0100 Subject: [PATCH] Look in more places for URL, short version and version. --- .../Homebrew/livecheck/strategy/sparkle.rb | 21 ++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/Library/Homebrew/livecheck/strategy/sparkle.rb b/Library/Homebrew/livecheck/strategy/sparkle.rb index dc17081e38..87fd431479 100644 --- a/Library/Homebrew/livecheck/strategy/sparkle.rb +++ b/Library/Homebrew/livecheck/strategy/sparkle.rb @@ -58,17 +58,24 @@ module Homebrew items = xml.xpath("//rss//channel//item").map do |item| enclosure = (item > "enclosure").first - next unless enclosure + url = enclosure&.attr("url") + short_version = enclosure&.attr("shortVersionString") + version = enclosure&.attr("version") - short_version ||= enclosure["shortVersionString"] - version ||= enclosure["version"] + url ||= (item > "link").first&.text + short_version ||= (item > "shortVersionString").first&.text&.strip + version ||= (item > "version").first&.text&.strip - short_version ||= (item > "shortVersionString").first&.text - version ||= (item > "version").first&.text + title = (item > "title").first&.text&.strip + + if match = title&.match(/(\d+(?:\.\d+)*)\s*(\([^)]+\))?\Z/) + short_version ||= match[1] + version ||= match[2] + end data = { - title: (item > "title").first&.text, - url: enclosure["url"], + title: title, + url: url, bundle_version: short_version || version ? BundleVersion.new(short_version, version) : nil, }.compact