Rename FollowRedirection to HeaderMatch.

This commit is contained in:
Markus Reiter 2020-12-14 02:49:32 +01:00 committed by Sam Ford
parent f76b5f105f
commit cf40f7b8f6
No known key found for this signature in database
GPG Key ID: 95209E46C7FFDEFE
2 changed files with 8 additions and 7 deletions

View File

@ -130,11 +130,11 @@ require_relative "strategy/github_latest"
require_relative "strategy/gnome"
require_relative "strategy/gnu"
require_relative "strategy/hackage"
require_relative "strategy/header_match"
require_relative "strategy/launchpad"
require_relative "strategy/npm"
require_relative "strategy/page_match"
require_relative "strategy/pypi"
require_relative "strategy/follow_redirection"
require_relative "strategy/sourceforge"
require_relative "strategy/sparkle"
require_relative "strategy/xorg"

View File

@ -6,22 +6,23 @@ require_relative "page_match"
module Homebrew
module Livecheck
module Strategy
# The {FollowRedirection} strategy follows all URL redirections and scans
# the final URL for matching text using the provided regex.
# The {HeaderMatch} strategy follows all URL redirections and scans
# the resulting headers for matching text using the provided regex.
#
# @api private
class FollowRedirection
class HeaderMatch
extend T::Sig
NICE_NAME = "Follow HTTP Redirection"
NICE_NAME = "Match HTTP Headers"
# We set the priority to zero since this cannot
# be detected automatically.
PRIORITY = 0
# Whether the strategy can be applied to the provided URL.
# FollowRedirection will technically match any HTTP URL but is
# only usable with a `livecheck` block containing a regex.
# The strategy will technically match any HTTP URL but is
# only usable with a `livecheck` block containing a regex
# or block.
sig { params(url: String).returns(T::Boolean) }
def self.match?(url)
url.match?(%r{^https?://})