Clean up files that use to include cachable
These were changed to extend to make it easier to determine where the classes come to in the extended callback but that means that the file is somewhat inconsistent. On the one hand we're using class methods and on the other we're extend self. This cleans that up but now the diff is atrocious and the blame is even worse. Oh well...
This commit is contained in:
parent
5cc1c85a5f
commit
bea2dc65fe
@ -12,16 +12,15 @@ module Homebrew
|
||||
module Cask
|
||||
extend Cachable
|
||||
|
||||
class << self
|
||||
private :cache
|
||||
private_class_method :cache
|
||||
|
||||
sig { params(token: String).returns(Hash) }
|
||||
def fetch(token)
|
||||
def self.fetch(token)
|
||||
Homebrew::API.fetch "cask/#{token}.json"
|
||||
end
|
||||
|
||||
sig { params(cask: ::Cask::Cask).returns(::Cask::Cask) }
|
||||
def source_download(cask)
|
||||
def self.source_download(cask)
|
||||
path = cask.ruby_source_path.to_s || "Casks/#{cask.token}.rb"
|
||||
sha256 = cask.ruby_source_checksum[:sha256]
|
||||
checksum = Checksum.new(sha256) if sha256
|
||||
@ -42,7 +41,7 @@ module Homebrew
|
||||
end
|
||||
|
||||
sig { returns(T::Boolean) }
|
||||
def download_and_cache_data!
|
||||
def self.download_and_cache_data!
|
||||
json_casks, updated = Homebrew::API.fetch_json_api_file "cask.jws.json"
|
||||
|
||||
cache["renames"] = {}
|
||||
@ -58,10 +57,10 @@ module Homebrew
|
||||
|
||||
updated
|
||||
end
|
||||
private :download_and_cache_data!
|
||||
private_class_method :download_and_cache_data!
|
||||
|
||||
sig { returns(T::Hash[String, Hash]) }
|
||||
def all_casks
|
||||
def self.all_casks
|
||||
unless cache.key?("casks")
|
||||
json_updated = download_and_cache_data!
|
||||
write_names(regenerate: json_updated)
|
||||
@ -71,7 +70,7 @@ module Homebrew
|
||||
end
|
||||
|
||||
sig { returns(T::Hash[String, String]) }
|
||||
def all_renames
|
||||
def self.all_renames
|
||||
unless cache.key?("renames")
|
||||
json_updated = download_and_cache_data!
|
||||
write_names(regenerate: json_updated)
|
||||
@ -81,12 +80,11 @@ module Homebrew
|
||||
end
|
||||
|
||||
sig { params(regenerate: T::Boolean).void }
|
||||
def write_names(regenerate: false)
|
||||
def self.write_names(regenerate: false)
|
||||
download_and_cache_data! unless cache.key?("casks")
|
||||
|
||||
Homebrew::API.write_names_file(all_casks.keys, "cask", regenerate: regenerate)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -12,16 +12,15 @@ module Homebrew
|
||||
module Formula
|
||||
extend Cachable
|
||||
|
||||
class << self
|
||||
private :cache
|
||||
private_class_method :cache
|
||||
|
||||
sig { params(name: String).returns(Hash) }
|
||||
def fetch(name)
|
||||
def self.fetch(name)
|
||||
Homebrew::API.fetch "formula/#{name}.json"
|
||||
end
|
||||
|
||||
sig { params(formula: ::Formula).returns(::Formula) }
|
||||
def source_download(formula)
|
||||
def self.source_download(formula)
|
||||
path = formula.ruby_source_path || "Formula/#{formula.name}.rb"
|
||||
git_head = formula.tap_git_head || "HEAD"
|
||||
tap = formula.tap&.full_name || "Homebrew/homebrew-core"
|
||||
@ -39,7 +38,7 @@ module Homebrew
|
||||
end
|
||||
|
||||
sig { returns(T::Boolean) }
|
||||
def download_and_cache_data!
|
||||
def self.download_and_cache_data!
|
||||
json_formulae, updated = Homebrew::API.fetch_json_api_file "formula.jws.json"
|
||||
|
||||
cache["aliases"] = {}
|
||||
@ -57,10 +56,10 @@ module Homebrew
|
||||
|
||||
updated
|
||||
end
|
||||
private :download_and_cache_data!
|
||||
private_class_method :download_and_cache_data!
|
||||
|
||||
sig { returns(T::Hash[String, Hash]) }
|
||||
def all_formulae
|
||||
def self.all_formulae
|
||||
unless cache.key?("formulae")
|
||||
json_updated = download_and_cache_data!
|
||||
write_names_and_aliases(regenerate: json_updated)
|
||||
@ -70,7 +69,7 @@ module Homebrew
|
||||
end
|
||||
|
||||
sig { returns(T::Hash[String, String]) }
|
||||
def all_aliases
|
||||
def self.all_aliases
|
||||
unless cache.key?("aliases")
|
||||
json_updated = download_and_cache_data!
|
||||
write_names_and_aliases(regenerate: json_updated)
|
||||
@ -80,7 +79,7 @@ module Homebrew
|
||||
end
|
||||
|
||||
sig { returns(T::Hash[String, String]) }
|
||||
def all_renames
|
||||
def self.all_renames
|
||||
unless cache.key?("renames")
|
||||
json_updated = download_and_cache_data!
|
||||
write_names_and_aliases(regenerate: json_updated)
|
||||
@ -90,7 +89,7 @@ module Homebrew
|
||||
end
|
||||
|
||||
sig { params(regenerate: T::Boolean).void }
|
||||
def write_names_and_aliases(regenerate: false)
|
||||
def self.write_names_and_aliases(regenerate: false)
|
||||
download_and_cache_data! unless cache.key?("formulae")
|
||||
|
||||
return unless Homebrew::API.write_names_file(all_formulae.keys, "formula", regenerate: regenerate)
|
||||
@ -103,5 +102,4 @@ module Homebrew
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -10,17 +10,15 @@ require "system_command"
|
||||
# @api private
|
||||
module Readall
|
||||
extend Cachable
|
||||
|
||||
class << self
|
||||
include SystemCommand::Mixin
|
||||
extend SystemCommand::Mixin
|
||||
|
||||
# TODO: remove this once the `MacOS` module is undefined on Linux
|
||||
MACOS_MODULE_REGEX = /\b(MacOS|OS::Mac)(\.|::)\b/
|
||||
private_constant :MACOS_MODULE_REGEX
|
||||
|
||||
private :cache
|
||||
private_class_method :cache
|
||||
|
||||
def valid_ruby_syntax?(ruby_files)
|
||||
def self.valid_ruby_syntax?(ruby_files)
|
||||
failed = T.let(false, T::Boolean)
|
||||
ruby_files.each do |ruby_file|
|
||||
# As a side effect, print syntax errors/warnings to `$stderr`.
|
||||
@ -29,7 +27,7 @@ module Readall
|
||||
!failed
|
||||
end
|
||||
|
||||
def valid_aliases?(alias_dir, formula_dir)
|
||||
def self.valid_aliases?(alias_dir, formula_dir)
|
||||
return true unless alias_dir.directory?
|
||||
|
||||
failed = T.let(false, T::Boolean)
|
||||
@ -50,7 +48,7 @@ module Readall
|
||||
!failed
|
||||
end
|
||||
|
||||
def valid_formulae?(tap, bottle_tag: nil)
|
||||
def self.valid_formulae?(tap, bottle_tag: nil)
|
||||
cache[:valid_formulae] ||= {}
|
||||
|
||||
success = T.let(true, T::Boolean)
|
||||
@ -83,11 +81,12 @@ module Readall
|
||||
success
|
||||
end
|
||||
|
||||
def valid_casks?(_tap, os_name: nil, arch: nil)
|
||||
def self.valid_casks?(_tap, os_name: nil, arch: nil)
|
||||
true
|
||||
end
|
||||
|
||||
def valid_tap?(tap, aliases: false, no_simulate: false, os_arch_combinations: OnSystem::ALL_OS_ARCH_COMBINATIONS)
|
||||
def self.valid_tap?(tap, aliases: false, no_simulate: false,
|
||||
os_arch_combinations: OnSystem::ALL_OS_ARCH_COMBINATIONS)
|
||||
success = true
|
||||
|
||||
if aliases
|
||||
@ -113,9 +112,7 @@ module Readall
|
||||
success
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def syntax_errors_or_warnings?(filename)
|
||||
private_class_method def self.syntax_errors_or_warnings?(filename)
|
||||
# Retrieve messages about syntax errors/warnings printed to `$stderr`.
|
||||
_, err, status = system_command(RUBY_PATH, args: ["-c", "-w", filename], print_stderr: false)
|
||||
|
||||
@ -131,7 +128,6 @@ module Readall
|
||||
# warnings we also need to inspect the output to `$stderr`.
|
||||
!status.success? || !messages.chomp.empty?
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
require "extend/os/readall"
|
||||
|
Loading…
x
Reference in New Issue
Block a user