mirror of
https://github.com/Homebrew/brew.git
synced 2025-07-14 16:09:03 +08:00
tap: add constants for json files
This commit is contained in:
parent
b4d4f6d504
commit
4ae72e0bdf
@ -1190,14 +1190,8 @@ module Homebrew
|
|||||||
audit_tap_audit_exceptions
|
audit_tap_audit_exceptions
|
||||||
end
|
end
|
||||||
|
|
||||||
HOMEBREW_TAP_JSON_FILES = %w[
|
|
||||||
formula_renames.json
|
|
||||||
tap_migrations.json
|
|
||||||
audit_exceptions/*.json
|
|
||||||
].freeze
|
|
||||||
|
|
||||||
def audit_json_files
|
def audit_json_files
|
||||||
json_patterns = HOMEBREW_TAP_JSON_FILES.map { |pattern| @path/pattern }
|
json_patterns = Tap::HOMEBREW_TAP_JSON_FILES.map { |pattern| @path/pattern }
|
||||||
Pathname.glob(json_patterns).each do |file|
|
Pathname.glob(json_patterns).each do |file|
|
||||||
JSON.parse file.read
|
JSON.parse file.read
|
||||||
rescue JSON::ParserError
|
rescue JSON::ParserError
|
||||||
|
@ -16,6 +16,16 @@ class Tap
|
|||||||
|
|
||||||
TAP_DIRECTORY = (HOMEBREW_LIBRARY/"Taps").freeze
|
TAP_DIRECTORY = (HOMEBREW_LIBRARY/"Taps").freeze
|
||||||
|
|
||||||
|
HOMEBREW_TAP_FORMULA_RENAMES_FILE = "formula_renames.json"
|
||||||
|
HOMEBREW_TAP_MIGRATIONS_FILE = "tap_migrations.json"
|
||||||
|
HOMEBREW_TAP_AUDIT_EXCEPTIONS_DIR = "audit_exceptions"
|
||||||
|
|
||||||
|
HOMEBREW_TAP_JSON_FILES = %W[
|
||||||
|
#{HOMEBREW_TAP_FORMULA_RENAMES_FILE}
|
||||||
|
#{HOMEBREW_TAP_MIGRATIONS_FILE}
|
||||||
|
#{HOMEBREW_TAP_AUDIT_EXCEPTIONS_DIR}/*.json
|
||||||
|
].freeze
|
||||||
|
|
||||||
def self.fetch(*args)
|
def self.fetch(*args)
|
||||||
case args.length
|
case args.length
|
||||||
when 1
|
when 1
|
||||||
@ -526,7 +536,7 @@ class Tap
|
|||||||
|
|
||||||
# Hash with tap formula renames
|
# Hash with tap formula renames
|
||||||
def formula_renames
|
def formula_renames
|
||||||
@formula_renames ||= if (rename_file = path/"formula_renames.json").file?
|
@formula_renames ||= if (rename_file = path/HOMEBREW_TAP_FORMULA_RENAMES_FILE).file?
|
||||||
JSON.parse(rename_file.read)
|
JSON.parse(rename_file.read)
|
||||||
else
|
else
|
||||||
{}
|
{}
|
||||||
@ -535,7 +545,7 @@ class Tap
|
|||||||
|
|
||||||
# Hash with tap migrations
|
# Hash with tap migrations
|
||||||
def tap_migrations
|
def tap_migrations
|
||||||
@tap_migrations ||= if (migration_file = path/"tap_migrations.json").file?
|
@tap_migrations ||= if (migration_file = path/HOMEBREW_TAP_MIGRATIONS_FILE).file?
|
||||||
JSON.parse(migration_file.read)
|
JSON.parse(migration_file.read)
|
||||||
else
|
else
|
||||||
{}
|
{}
|
||||||
@ -546,7 +556,7 @@ class Tap
|
|||||||
def audit_exceptions
|
def audit_exceptions
|
||||||
@audit_exceptions = {}
|
@audit_exceptions = {}
|
||||||
|
|
||||||
Pathname.glob(path/"audit_exceptions/*").each do |exception_file|
|
Pathname.glob(path/HOMEBREW_TAP_AUDIT_EXCEPTIONS_DIR/"*").each do |exception_file|
|
||||||
list_name = exception_file.basename.to_s.chomp(".json").to_sym
|
list_name = exception_file.basename.to_s.chomp(".json").to_sym
|
||||||
list_contents = begin
|
list_contents = begin
|
||||||
JSON.parse exception_file.read
|
JSON.parse exception_file.read
|
||||||
|
Loading…
x
Reference in New Issue
Block a user