Merge pull request #11839 from Rylan12/fix-api-paths

api: fix generic api path functions
This commit is contained in:
Rylan Polster 2021-08-09 18:59:31 -04:00 committed by GitHub
commit 764959b73a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 124 additions and 124 deletions

View File

@ -7,10 +7,9 @@ module Homebrew
#
# @api private
module Analytics
class << self
extend T::Sig
module_function
sig { returns(String) }
def analytics_api_path
"analytics"
@ -23,6 +22,7 @@ module Homebrew
end
end
end
end
end
require "extend/os/api/analytics"

View File

@ -9,10 +9,9 @@ module Homebrew
#
# @api private
module Bottle
class << self
extend T::Sig
module_function
sig { returns(String) }
def bottle_api_path
"bottle"
@ -67,7 +66,7 @@ module Homebrew
match[:sha256]
end
sig { params(hash: Hash, tag: Symbol).void }
sig { params(hash: Hash, tag: String).void }
def download_bottle(hash, tag)
bottle = hash["bottles"][tag]
bottle ||= hash["bottles"]["all"]
@ -90,6 +89,7 @@ module Homebrew
end
end
end
end
end
require "extend/os/api/bottle"

View File

@ -7,14 +7,14 @@ module Homebrew
#
# @api private
module Cask
class << self
extend T::Sig
module_function
sig { params(name: String).returns(Hash) }
def fetch(name)
Homebrew::API.fetch "cask/#{name}.json"
end
end
end
end
end

View File

@ -7,10 +7,9 @@ module Homebrew
#
# @api private
module Formula
class << self
extend T::Sig
module_function
sig { returns(String) }
def formula_api_path
"formula"
@ -23,6 +22,7 @@ module Homebrew
end
end
end
end
end
require "extend/os/api/formula"

View File

@ -7,10 +7,9 @@ module Homebrew
#
# @api private
module Versions
class << self
extend T::Sig
module_function
def formulae
# The result is cached by Homebrew::API.fetch
Homebrew::API.fetch "versions-formulae.json"
@ -49,4 +48,5 @@ module Homebrew
end
end
end
end
end

View File

@ -190,7 +190,7 @@ module Utils
def formula_output(f, args:)
return if Homebrew::EnvConfig.no_analytics? || Homebrew::EnvConfig.no_github_api?
json = Homebrew::API::Formula.fetch f
json = Homebrew::API::Formula.fetch f.name
return if json.blank? || json["analytics"].blank?
get_analytics(json, args: args)
@ -202,7 +202,7 @@ module Utils
def cask_output(cask, args:)
return if Homebrew::EnvConfig.no_analytics? || Homebrew::EnvConfig.no_github_api?
json = Homebrew::API::Cask.fetch cask
json = Homebrew::API::Cask.fetch cask.token
return if json.blank? || json["analytics"].blank?
get_analytics(json, args: args)