Merge pull request #14830 from samford/livecheck/rework-json-match
Strategy#from_url: Amend conditions for Json
This commit is contained in:
commit
4986a1aa26
@ -151,25 +151,25 @@ module Homebrew
|
||||
).returns(T::Array[T.untyped])
|
||||
}
|
||||
def from_url(url, livecheck_strategy: nil, url_provided: false, regex_provided: false, block_provided: false)
|
||||
usable_strategies = strategies.values.select do |strategy|
|
||||
usable_strategies = strategies.select do |strategy_symbol, strategy|
|
||||
if strategy == PageMatch
|
||||
# Only treat the strategy as usable if the `livecheck` block
|
||||
# contains a regex and/or `strategy` block
|
||||
next if !regex_provided && !block_provided
|
||||
elsif strategy == Json
|
||||
# Only treat the strategy as usable if the `livecheck` block
|
||||
# contains a `strategy` block
|
||||
next unless block_provided
|
||||
# specifies the strategy and contains a `strategy` block
|
||||
next if (livecheck_strategy != strategy_symbol) || !block_provided
|
||||
elsif strategy.const_defined?(:PRIORITY) &&
|
||||
!strategy::PRIORITY.positive? &&
|
||||
from_symbol(livecheck_strategy) != strategy
|
||||
livecheck_strategy != strategy_symbol
|
||||
# Ignore strategies with a priority of 0 or lower, unless the
|
||||
# strategy is specified in the `livecheck` block
|
||||
next
|
||||
end
|
||||
|
||||
strategy.respond_to?(:match?) && strategy.match?(url)
|
||||
end
|
||||
end.values
|
||||
|
||||
# Sort usable strategies in descending order by priority, using the
|
||||
# DEFAULT_PRIORITY when a strategy doesn't contain a PRIORITY constant
|
||||
|
Loading…
x
Reference in New Issue
Block a user