utils/repology: use project-by tool to retrieve Formula data
This commit is contained in:
parent
61ff1d7e74
commit
4fa01fc8b7
@ -62,7 +62,7 @@ module Homebrew
|
||||
repo["repo"] == "homebrew"
|
||||
end
|
||||
|
||||
next if homebrew_repo.blank? # TODO: check if/when this ever happens
|
||||
next if homebrew_repo.blank?
|
||||
|
||||
formula = begin
|
||||
Formula[homebrew_repo["srcname"]]
|
||||
|
@ -21,16 +21,19 @@ module Repology
|
||||
end
|
||||
|
||||
def single_package_query(name)
|
||||
url = "https://repology.org/api/v1/project/#{name}"
|
||||
url = %W[
|
||||
https://repology.org/tools/project-by?repo=homebrew&
|
||||
name_type=srcname&target_page=api_v1_project&name=#{name}
|
||||
].join
|
||||
|
||||
output, _errors, _status = curl_output(url.to_s)
|
||||
output, _errors, _status = curl_output("--location", url.to_s)
|
||||
|
||||
begin
|
||||
data = JSON.parse(output)
|
||||
|
||||
homebrew = data.select do |repo|
|
||||
repo["repo"] == "homebrew"
|
||||
{ name => data }
|
||||
rescue
|
||||
nil
|
||||
end
|
||||
|
||||
homebrew.empty? ? nil : { name => data }
|
||||
end
|
||||
|
||||
def parse_api_response(limit = nil)
|
||||
@ -59,7 +62,8 @@ module Repology
|
||||
end
|
||||
|
||||
def latest_version(repositories)
|
||||
# TODO: explain unique
|
||||
# The status is "unique" when the package is present only in Homebrew, so Repology
|
||||
# has no way of knowing if the package is up-to-date.
|
||||
is_unique = repositories.find do |repo|
|
||||
repo["status"] == "unique"
|
||||
end.present?
|
||||
@ -70,7 +74,7 @@ module Repology
|
||||
repo["status"] == "newest"
|
||||
end
|
||||
|
||||
# TODO: explain when latest can be blank
|
||||
# Repology cannot identify "newest" versions for packages without a version scheme
|
||||
return "no latest version" if latest_version.blank?
|
||||
|
||||
latest_version["version"]
|
||||
|
Loading…
x
Reference in New Issue
Block a user