Improve consistency of *_version methods
Minimizing the differences between the `#resource_version` and `#latest_version` methods will help to ease the process of potentially merging them into one method in the future.
This commit is contained in:
parent
7ffeba6380
commit
fb653c00d8
@ -779,7 +779,6 @@ module Homebrew
|
|||||||
version.to_s.include?(rejection)
|
version.to_s.include?(rejection)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
next if match_version_map.blank?
|
next if match_version_map.blank?
|
||||||
|
|
||||||
if debug
|
if debug
|
||||||
@ -878,7 +877,6 @@ module Homebrew
|
|||||||
urls ||= checkable_urls(resource)
|
urls ||= checkable_urls(resource)
|
||||||
|
|
||||||
checked_urls = []
|
checked_urls = []
|
||||||
|
|
||||||
# rubocop:disable Metrics/BlockLength
|
# rubocop:disable Metrics/BlockLength
|
||||||
urls.each_with_index do |original_url, i|
|
urls.each_with_index do |original_url, i|
|
||||||
# Only preprocess the URL when it's appropriate
|
# Only preprocess the URL when it's appropriate
|
||||||
@ -896,7 +894,6 @@ module Homebrew
|
|||||||
regex_provided: livecheck_regex.present?,
|
regex_provided: livecheck_regex.present?,
|
||||||
block_provided: livecheck_strategy_block.present?,
|
block_provided: livecheck_strategy_block.present?,
|
||||||
)
|
)
|
||||||
|
|
||||||
strategy = Strategy.from_symbol(livecheck_strategy) || strategies.first
|
strategy = Strategy.from_symbol(livecheck_strategy) || strategies.first
|
||||||
strategy_name = livecheck_strategy_names[strategy]
|
strategy_name = livecheck_strategy_names[strategy]
|
||||||
|
|
||||||
@ -929,8 +926,10 @@ module Homebrew
|
|||||||
next if strategy.blank?
|
next if strategy.blank?
|
||||||
|
|
||||||
strategy_data = strategy.find_versions(
|
strategy_data = strategy.find_versions(
|
||||||
url: url, regex: livecheck_regex,
|
url: url,
|
||||||
homebrew_curl: false, &livecheck_strategy_block
|
regex: livecheck_regex,
|
||||||
|
homebrew_curl: false,
|
||||||
|
&livecheck_strategy_block
|
||||||
)
|
)
|
||||||
match_version_map = strategy_data[:matches]
|
match_version_map = strategy_data[:matches]
|
||||||
regex = strategy_data[:regex]
|
regex = strategy_data[:regex]
|
||||||
@ -1008,9 +1007,7 @@ module Homebrew
|
|||||||
resource_version_info[:meta][:url][:final] = strategy_data[:final_url] if strategy_data[:final_url]
|
resource_version_info[:meta][:url][:final] = strategy_data[:final_url] if strategy_data[:final_url]
|
||||||
resource_version_info[:meta][:strategy] = strategy.present? ? strategy_name : nil
|
resource_version_info[:meta][:strategy] = strategy.present? ? strategy_name : nil
|
||||||
if strategies.present?
|
if strategies.present?
|
||||||
resource_version_info[:meta][:strategies] = strategies.map do |s|
|
resource_version_info[:meta][:strategies] = strategies.map { |s| livecheck_strategy_names[s] }
|
||||||
livecheck_strategy_names[s]
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
resource_version_info[:meta][:regex] = regex.inspect if regex.present?
|
resource_version_info[:meta][:regex] = regex.inspect if regex.present?
|
||||||
resource_version_info[:meta][:cached] = true if strategy_data[:cached] == true
|
resource_version_info[:meta][:cached] = true if strategy_data[:cached] == true
|
||||||
|
Loading…
x
Reference in New Issue
Block a user