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"
|
repo["repo"] == "homebrew"
|
||||||
end
|
end
|
||||||
|
|
||||||
next if homebrew_repo.blank? # TODO: check if/when this ever happens
|
next if homebrew_repo.blank?
|
||||||
|
|
||||||
formula = begin
|
formula = begin
|
||||||
Formula[homebrew_repo["srcname"]]
|
Formula[homebrew_repo["srcname"]]
|
||||||
|
@ -21,16 +21,19 @@ module Repology
|
|||||||
end
|
end
|
||||||
|
|
||||||
def single_package_query(name)
|
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)
|
data = JSON.parse(output)
|
||||||
|
{ name => data }
|
||||||
homebrew = data.select do |repo|
|
rescue
|
||||||
repo["repo"] == "homebrew"
|
nil
|
||||||
end
|
end
|
||||||
|
|
||||||
homebrew.empty? ? nil : { name => data }
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def parse_api_response(limit = nil)
|
def parse_api_response(limit = nil)
|
||||||
@ -59,7 +62,8 @@ module Repology
|
|||||||
end
|
end
|
||||||
|
|
||||||
def latest_version(repositories)
|
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|
|
is_unique = repositories.find do |repo|
|
||||||
repo["status"] == "unique"
|
repo["status"] == "unique"
|
||||||
end.present?
|
end.present?
|
||||||
@ -70,7 +74,7 @@ module Repology
|
|||||||
repo["status"] == "newest"
|
repo["status"] == "newest"
|
||||||
end
|
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?
|
return "no latest version" if latest_version.blank?
|
||||||
|
|
||||||
latest_version["version"]
|
latest_version["version"]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user