Remove misleading upstream.rbi, enable types in on_system
This commit is contained in:
parent
98a2923463
commit
92b99b3132
@ -169,10 +169,12 @@ module Cask
|
|||||||
|
|
||||||
DEFAULT_DIRS.each_key do |dir|
|
DEFAULT_DIRS.each_key do |dir|
|
||||||
define_method(dir) do
|
define_method(dir) do
|
||||||
|
T.bind(self, Config)
|
||||||
explicit.fetch(dir, env.fetch(dir, default.fetch(dir)))
|
explicit.fetch(dir, env.fetch(dir, default.fetch(dir)))
|
||||||
end
|
end
|
||||||
|
|
||||||
define_method(:"#{dir}=") do |path|
|
define_method(:"#{dir}=") do |path|
|
||||||
|
T.bind(self, Config)
|
||||||
explicit[dir] = Pathname(path).expand_path
|
explicit[dir] = Pathname(path).expand_path
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@ -339,6 +339,7 @@ module Cask
|
|||||||
|
|
||||||
ORDINARY_ARTIFACT_CLASSES.each do |klass|
|
ORDINARY_ARTIFACT_CLASSES.each do |klass|
|
||||||
define_method(klass.dsl_key) do |*args, **kwargs|
|
define_method(klass.dsl_key) do |*args, **kwargs|
|
||||||
|
T.bind(self, DSL)
|
||||||
if [*artifacts.map(&:class), klass].include?(Artifact::StageOnly) &&
|
if [*artifacts.map(&:class), klass].include?(Artifact::StageOnly) &&
|
||||||
(artifacts.map(&:class) & ACTIVATABLE_ARTIFACT_CLASSES).any?
|
(artifacts.map(&:class) & ACTIVATABLE_ARTIFACT_CLASSES).any?
|
||||||
raise CaskInvalidError.new(cask, "'stage_only' must be the only activatable artifact.")
|
raise CaskInvalidError.new(cask, "'stage_only' must be the only activatable artifact.")
|
||||||
@ -355,6 +356,7 @@ module Cask
|
|||||||
ARTIFACT_BLOCK_CLASSES.each do |klass|
|
ARTIFACT_BLOCK_CLASSES.each do |klass|
|
||||||
[klass.dsl_key, klass.uninstall_dsl_key].each do |dsl_key|
|
[klass.dsl_key, klass.uninstall_dsl_key].each do |dsl_key|
|
||||||
define_method(dsl_key) do |&block|
|
define_method(dsl_key) do |&block|
|
||||||
|
T.bind(self, DSL)
|
||||||
artifacts.add(klass.new(cask, dsl_key => block))
|
artifacts.add(klass.new(cask, dsl_key => block))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@ -32,6 +32,7 @@ module Cask
|
|||||||
def define_divider_deletion_method(divider)
|
def define_divider_deletion_method(divider)
|
||||||
method_name = deletion_method_name(divider)
|
method_name = deletion_method_name(divider)
|
||||||
define_method(method_name) do
|
define_method(method_name) do
|
||||||
|
T.bind(self, Version)
|
||||||
version { delete(divider) }
|
version { delete(divider) }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -49,6 +50,7 @@ module Cask
|
|||||||
def define_divider_conversion_method(left_divider, right_divider)
|
def define_divider_conversion_method(left_divider, right_divider)
|
||||||
method_name = conversion_method_name(left_divider, right_divider)
|
method_name = conversion_method_name(left_divider, right_divider)
|
||||||
define_method(method_name) do
|
define_method(method_name) do
|
||||||
|
T.bind(self, Version)
|
||||||
version { gsub(left_divider, right_divider) }
|
version { gsub(left_divider, right_divider) }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
# typed: false
|
# typed: true
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
require "simulate_system"
|
require "simulate_system"
|
||||||
@ -9,17 +9,15 @@ module OnSystem
|
|||||||
ARCH_OPTIONS = [:intel, :arm].freeze
|
ARCH_OPTIONS = [:intel, :arm].freeze
|
||||||
BASE_OS_OPTIONS = [:macos, :linux].freeze
|
BASE_OS_OPTIONS = [:macos, :linux].freeze
|
||||||
|
|
||||||
module_function
|
|
||||||
|
|
||||||
sig { params(arch: Symbol).returns(T::Boolean) }
|
sig { params(arch: Symbol).returns(T::Boolean) }
|
||||||
def arch_condition_met?(arch)
|
def self.arch_condition_met?(arch)
|
||||||
raise ArgumentError, "Invalid arch condition: #{arch.inspect}" if ARCH_OPTIONS.exclude?(arch)
|
raise ArgumentError, "Invalid arch condition: #{arch.inspect}" if ARCH_OPTIONS.exclude?(arch)
|
||||||
|
|
||||||
arch == Homebrew::SimulateSystem.current_arch
|
arch == Homebrew::SimulateSystem.current_arch
|
||||||
end
|
end
|
||||||
|
|
||||||
sig { params(os_name: Symbol, or_condition: T.nilable(Symbol)).returns(T::Boolean) }
|
sig { params(os_name: Symbol, or_condition: T.nilable(Symbol)).returns(T::Boolean) }
|
||||||
def os_condition_met?(os_name, or_condition = nil)
|
def self.os_condition_met?(os_name, or_condition = nil)
|
||||||
return Homebrew::SimulateSystem.send("simulating_or_running_on_#{os_name}?") if BASE_OS_OPTIONS.include?(os_name)
|
return Homebrew::SimulateSystem.send("simulating_or_running_on_#{os_name}?") if BASE_OS_OPTIONS.include?(os_name)
|
||||||
|
|
||||||
raise ArgumentError, "Invalid OS condition: #{os_name.inspect}" unless MacOSVersions::SYMBOLS.key?(os_name)
|
raise ArgumentError, "Invalid OS condition: #{os_name.inspect}" unless MacOSVersions::SYMBOLS.key?(os_name)
|
||||||
@ -46,17 +44,17 @@ module OnSystem
|
|||||||
end
|
end
|
||||||
|
|
||||||
sig { params(method_name: Symbol).returns(Symbol) }
|
sig { params(method_name: Symbol).returns(Symbol) }
|
||||||
def condition_from_method_name(method_name)
|
def self.condition_from_method_name(method_name)
|
||||||
method_name.to_s.sub(/^on_/, "").to_sym
|
method_name.to_s.sub(/^on_/, "").to_sym
|
||||||
end
|
end
|
||||||
|
|
||||||
sig { params(base: Class).void }
|
sig { params(base: Class).void }
|
||||||
def setup_arch_methods(base)
|
def self.setup_arch_methods(base)
|
||||||
ARCH_OPTIONS.each do |arch|
|
ARCH_OPTIONS.each do |arch|
|
||||||
base.define_method("on_#{arch}") do |&block|
|
base.define_method("on_#{arch}") do |&block|
|
||||||
@on_system_blocks_exist = true
|
@on_system_blocks_exist = true
|
||||||
|
|
||||||
return unless OnSystem.arch_condition_met? OnSystem.condition_from_method_name(__method__)
|
return unless OnSystem.arch_condition_met? OnSystem.condition_from_method_name(T.must(__method__))
|
||||||
|
|
||||||
@called_in_on_system_block = true
|
@called_in_on_system_block = true
|
||||||
result = block.call
|
result = block.call
|
||||||
@ -75,12 +73,12 @@ module OnSystem
|
|||||||
end
|
end
|
||||||
|
|
||||||
sig { params(base: Class).void }
|
sig { params(base: Class).void }
|
||||||
def setup_base_os_methods(base)
|
def self.setup_base_os_methods(base)
|
||||||
BASE_OS_OPTIONS.each do |base_os|
|
BASE_OS_OPTIONS.each do |base_os|
|
||||||
base.define_method("on_#{base_os}") do |&block|
|
base.define_method("on_#{base_os}") do |&block|
|
||||||
@on_system_blocks_exist = true
|
@on_system_blocks_exist = true
|
||||||
|
|
||||||
return unless OnSystem.os_condition_met? OnSystem.condition_from_method_name(__method__)
|
return unless OnSystem.os_condition_met? OnSystem.condition_from_method_name(T.must(__method__))
|
||||||
|
|
||||||
@called_in_on_system_block = true
|
@called_in_on_system_block = true
|
||||||
result = block.call
|
result = block.call
|
||||||
@ -118,12 +116,12 @@ module OnSystem
|
|||||||
end
|
end
|
||||||
|
|
||||||
sig { params(base: Class).void }
|
sig { params(base: Class).void }
|
||||||
def setup_macos_methods(base)
|
def self.setup_macos_methods(base)
|
||||||
MacOSVersions::SYMBOLS.each_key do |os_name|
|
MacOSVersions::SYMBOLS.each_key do |os_name|
|
||||||
base.define_method("on_#{os_name}") do |or_condition = nil, &block|
|
base.define_method("on_#{os_name}") do |or_condition = nil, &block|
|
||||||
@on_system_blocks_exist = true
|
@on_system_blocks_exist = true
|
||||||
|
|
||||||
os_condition = OnSystem.condition_from_method_name __method__
|
os_condition = OnSystem.condition_from_method_name T.must(__method__)
|
||||||
return unless OnSystem.os_condition_met? os_condition, or_condition
|
return unless OnSystem.os_condition_met? os_condition, or_condition
|
||||||
|
|
||||||
@called_in_on_system_block = true
|
@called_in_on_system_block = true
|
||||||
|
|||||||
@ -1,23 +0,0 @@
|
|||||||
# typed: strict
|
|
||||||
|
|
||||||
# This file contains temporary definitions for fixes that have
|
|
||||||
# been submitted upstream to https://github.com/sorbet/sorbet.
|
|
||||||
|
|
||||||
class Module
|
|
||||||
# https://github.com/sorbet/sorbet/pull/3732
|
|
||||||
sig do
|
|
||||||
params(
|
|
||||||
arg0: T.any(Symbol, String),
|
|
||||||
arg1: T.any(Proc, Method, UnboundMethod)
|
|
||||||
)
|
|
||||||
.returns(Symbol)
|
|
||||||
end
|
|
||||||
sig do
|
|
||||||
params(
|
|
||||||
arg0: T.any(Symbol, String),
|
|
||||||
blk: T.proc.bind(T.untyped).returns(T.untyped),
|
|
||||||
)
|
|
||||||
.returns(Symbol)
|
|
||||||
end
|
|
||||||
def define_method(arg0, arg1=T.unsafe(nil), &blk); end
|
|
||||||
end
|
|
||||||
Loading…
x
Reference in New Issue
Block a user