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])
|
).returns(T::Array[T.untyped])
|
||||||
}
|
}
|
||||||
def from_url(url, livecheck_strategy: nil, url_provided: false, regex_provided: false, block_provided: false)
|
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
|
if strategy == PageMatch
|
||||||
# Only treat the strategy as usable if the `livecheck` block
|
# Only treat the strategy as usable if the `livecheck` block
|
||||||
# contains a regex and/or `strategy` block
|
# contains a regex and/or `strategy` block
|
||||||
next if !regex_provided && !block_provided
|
next if !regex_provided && !block_provided
|
||||||
elsif strategy == Json
|
elsif strategy == Json
|
||||||
# Only treat the strategy as usable if the `livecheck` block
|
# Only treat the strategy as usable if the `livecheck` block
|
||||||
# contains a `strategy` block
|
# specifies the strategy and contains a `strategy` block
|
||||||
next unless block_provided
|
next if (livecheck_strategy != strategy_symbol) || !block_provided
|
||||||
elsif strategy.const_defined?(:PRIORITY) &&
|
elsif strategy.const_defined?(:PRIORITY) &&
|
||||||
!strategy::PRIORITY.positive? &&
|
!strategy::PRIORITY.positive? &&
|
||||||
from_symbol(livecheck_strategy) != strategy
|
livecheck_strategy != strategy_symbol
|
||||||
# Ignore strategies with a priority of 0 or lower, unless the
|
# Ignore strategies with a priority of 0 or lower, unless the
|
||||||
# strategy is specified in the `livecheck` block
|
# strategy is specified in the `livecheck` block
|
||||||
next
|
next
|
||||||
end
|
end
|
||||||
|
|
||||||
strategy.respond_to?(:match?) && strategy.match?(url)
|
strategy.respond_to?(:match?) && strategy.match?(url)
|
||||||
end
|
end.values
|
||||||
|
|
||||||
# Sort usable strategies in descending order by priority, using the
|
# Sort usable strategies in descending order by priority, using the
|
||||||
# DEFAULT_PRIORITY when a strategy doesn't contain a PRIORITY constant
|
# DEFAULT_PRIORITY when a strategy doesn't contain a PRIORITY constant
|
||||||
|
Loading…
x
Reference in New Issue
Block a user