mirror of
https://github.com/Homebrew/brew.git
synced 2025-07-14 16:09:03 +08:00
cask: move some files to strict Sorbet sigil.
This commit is contained in:
parent
768c10c6fb
commit
35407ab556
@ -1,4 +1,4 @@
|
|||||||
# typed: true # rubocop:todo Sorbet/StrictSigil
|
# typed: strict
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
require "cachable"
|
require "cachable"
|
||||||
@ -21,7 +21,7 @@ module Homebrew
|
|||||||
|
|
||||||
private_class_method :cache
|
private_class_method :cache
|
||||||
|
|
||||||
sig { params(token: String).returns(Hash) }
|
sig { params(token: String).returns(T::Hash[String, T.untyped]) }
|
||||||
def self.fetch(token)
|
def self.fetch(token)
|
||||||
Homebrew::API.fetch "cask/#{token}.json"
|
Homebrew::API.fetch "cask/#{token}.json"
|
||||||
end
|
end
|
||||||
@ -47,6 +47,7 @@ module Homebrew
|
|||||||
.load(config: cask.config)
|
.load(config: cask.config)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
sig { returns(Pathname) }
|
||||||
def self.cached_json_file_path
|
def self.cached_json_file_path
|
||||||
HOMEBREW_CACHE_API/api_filename
|
HOMEBREW_CACHE_API/api_filename
|
||||||
end
|
end
|
||||||
@ -70,7 +71,7 @@ module Homebrew
|
|||||||
end
|
end
|
||||||
private_class_method :download_and_cache_data!
|
private_class_method :download_and_cache_data!
|
||||||
|
|
||||||
sig { returns(T::Hash[String, Hash]) }
|
sig { returns(T::Hash[String, T::Hash[String, T.untyped]]) }
|
||||||
def self.all_casks
|
def self.all_casks
|
||||||
unless cache.key?("casks")
|
unless cache.key?("casks")
|
||||||
json_updated = download_and_cache_data!
|
json_updated = download_and_cache_data!
|
||||||
|
@ -1,9 +1,14 @@
|
|||||||
# typed: true # rubocop:todo Sorbet/StrictSigil
|
# typed: strict
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
module Cask
|
module Cask
|
||||||
# Sorted set containing all cask artifacts.
|
# Sorted set containing all cask artifacts.
|
||||||
class ArtifactSet < ::Set
|
class ArtifactSet < ::Set
|
||||||
|
extend T::Generic
|
||||||
|
|
||||||
|
Elem = type_member(:out) { { fixed: Artifact::AbstractArtifact } }
|
||||||
|
|
||||||
|
sig { params(block: T.nilable(T.proc.params(arg0: Elem).returns(T.untyped))).void }
|
||||||
def each(&block)
|
def each(&block)
|
||||||
return enum_for(T.must(__method__)) { size } unless block
|
return enum_for(T.must(__method__)) { size } unless block
|
||||||
|
|
||||||
@ -11,6 +16,7 @@ module Cask
|
|||||||
self
|
self
|
||||||
end
|
end
|
||||||
|
|
||||||
|
sig { returns(T::Array[Artifact::AbstractArtifact]) }
|
||||||
def to_a
|
def to_a
|
||||||
super.sort
|
super.sort
|
||||||
end
|
end
|
||||||
|
@ -295,7 +295,7 @@ module Cask
|
|||||||
sig { returns(Pathname) }
|
sig { returns(Pathname) }
|
||||||
attr_reader :path
|
attr_reader :path
|
||||||
|
|
||||||
sig { returns(T.nilable(T::Hash[T.any(String, Symbol), T.anything])) }
|
sig { returns(T.nilable(T::Hash[String, T.untyped])) }
|
||||||
attr_reader :from_json
|
attr_reader :from_json
|
||||||
|
|
||||||
sig {
|
sig {
|
||||||
@ -320,7 +320,7 @@ module Cask
|
|||||||
sig {
|
sig {
|
||||||
params(
|
params(
|
||||||
token: String,
|
token: String,
|
||||||
from_json: T.nilable(T::Hash[T.any(String, Symbol), T.anything]),
|
from_json: T.nilable(T::Hash[String, T.untyped]),
|
||||||
path: T.nilable(Pathname),
|
path: T.nilable(Pathname),
|
||||||
).void
|
).void
|
||||||
}
|
}
|
||||||
|
@ -304,6 +304,20 @@ on_request: true)
|
|||||||
|
|
||||||
next if artifact.is_a?(Artifact::Binary) && !binaries?
|
next if artifact.is_a?(Artifact::Binary) && !binaries?
|
||||||
|
|
||||||
|
artifact = T.cast(
|
||||||
|
artifact,
|
||||||
|
T.any(
|
||||||
|
Artifact::AbstractFlightBlock,
|
||||||
|
Artifact::Installer,
|
||||||
|
Artifact::KeyboardLayout,
|
||||||
|
Artifact::Mdimporter,
|
||||||
|
Artifact::Moved,
|
||||||
|
Artifact::Pkg,
|
||||||
|
Artifact::Qlplugin,
|
||||||
|
Artifact::Symlinked,
|
||||||
|
),
|
||||||
|
)
|
||||||
|
|
||||||
artifact.install_phase(
|
artifact.install_phase(
|
||||||
command: @command, verbose: verbose?, adopt: adopt?, auto_updates: @cask.auto_updates,
|
command: @command, verbose: verbose?, adopt: adopt?, auto_updates: @cask.auto_updates,
|
||||||
force: force?, predecessor:
|
force: force?, predecessor:
|
||||||
@ -549,6 +563,18 @@ on_request: true)
|
|||||||
|
|
||||||
artifacts.each do |artifact|
|
artifacts.each do |artifact|
|
||||||
if artifact.respond_to?(:uninstall_phase)
|
if artifact.respond_to?(:uninstall_phase)
|
||||||
|
artifact = T.cast(
|
||||||
|
artifact,
|
||||||
|
T.any(
|
||||||
|
Artifact::AbstractFlightBlock,
|
||||||
|
Artifact::KeyboardLayout,
|
||||||
|
Artifact::Moved,
|
||||||
|
Artifact::Qlplugin,
|
||||||
|
Artifact::Symlinked,
|
||||||
|
Artifact::Uninstall,
|
||||||
|
),
|
||||||
|
)
|
||||||
|
|
||||||
odebug "Uninstalling artifact of class #{artifact.class}"
|
odebug "Uninstalling artifact of class #{artifact.class}"
|
||||||
artifact.uninstall_phase(
|
artifact.uninstall_phase(
|
||||||
command: @command,
|
command: @command,
|
||||||
@ -563,6 +589,8 @@ on_request: true)
|
|||||||
|
|
||||||
next unless artifact.respond_to?(:post_uninstall_phase)
|
next unless artifact.respond_to?(:post_uninstall_phase)
|
||||||
|
|
||||||
|
artifact = T.cast(artifact, Artifact::Uninstall)
|
||||||
|
|
||||||
odebug "Post-uninstalling artifact of class #{artifact.class}"
|
odebug "Post-uninstalling artifact of class #{artifact.class}"
|
||||||
artifact.post_uninstall_phase(
|
artifact.post_uninstall_phase(
|
||||||
command: @command,
|
command: @command,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user