Sparkle: Refactor macOS os strings into constant

This commit is contained in:
Sam Ford 2023-11-16 11:25:18 -05:00
parent 491e2c4a80
commit 75ce7240fc
No known key found for this signature in database
GPG Key ID: 7AF5CBEE1DD6F76D

View File

@ -21,6 +21,9 @@ module Homebrew
# The `Regexp` used to determine if the strategy applies to the URL. # The `Regexp` used to determine if the strategy applies to the URL.
URL_MATCH_REGEX = %r{^https?://}i.freeze URL_MATCH_REGEX = %r{^https?://}i.freeze
# Common `os` values used in appcasts to refer to macOS.
APPCAST_MACOS_STRINGS = ["macos", "osx"].freeze
# Whether the strategy can be applied to the provided URL. # Whether the strategy can be applied to the provided URL.
# #
# @param url [String] the URL to match against # @param url [String] the URL to match against
@ -152,7 +155,7 @@ module Homebrew
def self.filter_items(items) def self.filter_items(items)
items.select do |item| items.select do |item|
# Omit items with an explicit `os` value that isn't macOS # Omit items with an explicit `os` value that isn't macOS
next false if item.os && !((item.os == "osx") || (item.os == "macos")) next false if item.os && APPCAST_MACOS_STRINGS.none?(item.os)
# Omit items for prerelease macOS versions # Omit items for prerelease macOS versions
next false if item.minimum_system_version&.strip_patch&.prerelease? next false if item.minimum_system_version&.strip_patch&.prerelease?