s/to_api_hash/to_internal_api_hash/

This commit is contained in:
apainintheneck 2024-03-04 22:42:07 -08:00
parent 12d5a40262
commit e0cea903ec
6 changed files with 14 additions and 14 deletions

View File

@ -359,7 +359,7 @@ module Cask
end
# @private
def to_api_hash
def to_internal_api_hash
api_hash = {
"token" => token,
"name" => name,
@ -408,7 +408,7 @@ module Cask
if loaded_from_api? && !Homebrew::EnvConfig.no_install_from_api?
return api_to_local_hash(Homebrew::API::Cask.all_casks[token].dup)
end
when :to_api_hash
when :to_internal_api_hash
raise ArgumentError, "API Hash must be generated from Ruby source files" if loaded_from_api?
else
raise ArgumentError, "Unknown hash method #{hash_method.inspect}"
@ -440,7 +440,7 @@ module Cask
end
end
hash["variations"] = variations if hash_method != :to_api_hash || variations.present?
hash["variations"] = variations if hash_method != :to_internal_api_hash || variations.present?
hash
end

View File

@ -75,7 +75,7 @@ module Homebrew
raise
end
homebrew_cask_tap_json = JSON.generate(tap.to_api_hash)
homebrew_cask_tap_json = JSON.generate(tap.to_internal_api_hash)
File.write("api/internal/v3/homebrew-cask.json", homebrew_cask_tap_json) unless args.dry_run?
end
end

View File

@ -74,7 +74,7 @@ module Homebrew
raise
end
homebrew_core_tap_json = JSON.generate(tap.to_api_hash)
homebrew_core_tap_json = JSON.generate(tap.to_internal_api_hash)
File.write("api/internal/v3/homebrew-core.json", homebrew_core_tap_json) unless args.dry_run?
canonical_json = JSON.pretty_generate(tap.formula_renames.merge(tap.alias_table))
File.write("_data/formula_canonical.json", "#{canonical_json}\n") unless args.dry_run?

View File

@ -2293,7 +2293,7 @@ class Formula
end
# @private
def to_api_hash
def to_internal_api_hash
api_hash = {
"desc" => desc,
"license" => SPDX.license_expression_to_string(license),
@ -2356,14 +2356,14 @@ class Formula
# @private
def to_hash_with_variations(hash_method: :to_hash)
if loaded_from_api? && hash_method == :to_api_hash
if loaded_from_api? && hash_method == :to_internal_api_hash
raise ArgumentError, "API Hash must be generated from Ruby source files"
end
namespace_prefix = case hash_method
when :to_hash
"Variations"
when :to_api_hash
when :to_internal_api_hash
"APIVariations"
else
raise ArgumentError, "Unknown hash method #{hash_method.inspect}"
@ -2404,7 +2404,7 @@ class Formula
end
end
hash["variations"] = variations if hash_method != :to_api_hash || variations.present?
hash["variations"] = variations if hash_method != :to_internal_api_hash || variations.present?
hash
end

View File

@ -1286,10 +1286,10 @@ class CoreTap < AbstractCoreTap
end
sig { returns(T::Hash[String, T.untyped]) }
def to_api_hash
def to_internal_api_hash
formulae_api_hash = formula_names.to_h do |name|
formula = Formulary.factory(name)
formula_hash = formula.to_hash_with_variations(hash_method: :to_api_hash)
formula_hash = formula.to_hash_with_variations(hash_method: :to_internal_api_hash)
[name, formula_hash]
end
@ -1372,10 +1372,10 @@ class CoreCaskTap < AbstractCoreTap
end
sig { returns(T::Hash[String, T.untyped]) }
def to_api_hash
def to_internal_api_hash
casks_api_hash = cask_tokens.to_h do |token|
cask = Cask::CaskLoader.load(token)
cask_hash = cask.to_hash_with_variations(hash_method: :to_api_hash)
cask_hash = cask.to_hash_with_variations(hash_method: :to_internal_api_hash)
[token, cask_hash]
end

View File

@ -17,7 +17,7 @@ RSpec.describe "Internal Tap JSON -- Formula" do
end
it "creates the expected hash" do
api_hash = CoreTap.instance.to_api_hash
api_hash = CoreTap.instance.to_internal_api_hash
api_hash["tap_git_head"] = tap_git_head # tricky to mock
expect(JSON.pretty_generate(api_hash)).to eq(internal_tap_json)