Use delegation to create Cask DSL methods
This commit is contained in:
parent
749e90078d
commit
d8c790dddc
@ -117,9 +117,7 @@ module Cask
|
||||
@dsl.language_eval
|
||||
end
|
||||
|
||||
::Cask::DSL::DSL_METHODS.each do |method_name|
|
||||
define_method(method_name) { |*args, &block| @dsl.send(method_name, *args, &block) }
|
||||
end
|
||||
def_delegators :@dsl, *::Cask::DSL::DSL_METHODS
|
||||
|
||||
sig { params(caskroom_path: Pathname).returns(T::Array[[String, String]]) }
|
||||
def timestamped_versions(caskroom_path: self.caskroom_path)
|
||||
|
@ -1,67 +0,0 @@
|
||||
# typed: strict
|
||||
|
||||
module Cask
|
||||
class Cask
|
||||
def appdir; end
|
||||
|
||||
def artifacts; end
|
||||
|
||||
def auto_updates; end
|
||||
|
||||
def caveats; end
|
||||
|
||||
def conflicts_with; end
|
||||
|
||||
def container; end
|
||||
|
||||
def depends_on; end
|
||||
|
||||
def desc; end
|
||||
|
||||
def discontinued?; end
|
||||
|
||||
def deprecated?; end
|
||||
|
||||
def deprecation_date; end
|
||||
|
||||
def deprecation_reason; end
|
||||
|
||||
def deprecation_replacement; end
|
||||
|
||||
def disabled?; end
|
||||
|
||||
def disable_date; end
|
||||
|
||||
def disable_reason; end
|
||||
|
||||
def disable_replacement; end
|
||||
|
||||
def homepage; end
|
||||
|
||||
def language; end
|
||||
|
||||
def languages; end
|
||||
|
||||
def livecheck; end
|
||||
|
||||
def livecheck_defined?; end
|
||||
|
||||
def livecheckable?; end
|
||||
|
||||
def name; end
|
||||
|
||||
def on_system_blocks_exist?; end
|
||||
|
||||
sig { returns(T.nilable(MacOSVersion)) }
|
||||
def on_system_block_min_os; end
|
||||
|
||||
def sha256; end
|
||||
|
||||
def staged_path; end
|
||||
|
||||
sig { returns(T.nilable(::Cask::URL)) }
|
||||
def url; end
|
||||
|
||||
def version; end
|
||||
end
|
||||
end
|
186
Library/Homebrew/sorbet/rbi/dsl/cask/cask.rbi
generated
186
Library/Homebrew/sorbet/rbi/dsl/cask/cask.rbi
generated
@ -6,6 +6,192 @@
|
||||
|
||||
|
||||
class Cask::Cask
|
||||
sig { params(args: T.untyped, block: T.untyped).returns(T.untyped) }
|
||||
def app(*args, &block); end
|
||||
|
||||
sig { params(args: T.untyped, block: T.untyped).returns(T.untyped) }
|
||||
def appcast(*args, &block); end
|
||||
|
||||
sig { params(args: T.untyped, block: T.untyped).returns(T.untyped) }
|
||||
def appdir(*args, &block); end
|
||||
|
||||
sig { params(args: T.untyped, block: T.untyped).returns(T.untyped) }
|
||||
def arch(*args, &block); end
|
||||
|
||||
sig { params(args: T.untyped, block: T.untyped).returns(T.untyped) }
|
||||
def artifact(*args, &block); end
|
||||
|
||||
sig { params(args: T.untyped, block: T.untyped).returns(T.untyped) }
|
||||
def artifacts(*args, &block); end
|
||||
|
||||
sig { params(args: T.untyped, block: T.untyped).returns(T.untyped) }
|
||||
def audio_unit_plugin(*args, &block); end
|
||||
|
||||
sig { params(args: T.untyped, block: T.untyped).returns(T.untyped) }
|
||||
def auto_updates(*args, &block); end
|
||||
|
||||
sig { params(args: T.untyped, block: T.untyped).returns(T.untyped) }
|
||||
def binary(*args, &block); end
|
||||
|
||||
sig { params(args: T.untyped, block: T.untyped).returns(T.untyped) }
|
||||
def caveats(*args, &block); end
|
||||
|
||||
sig { params(args: T.untyped, block: T.untyped).returns(T.untyped) }
|
||||
def colorpicker(*args, &block); end
|
||||
|
||||
sig { params(args: T.untyped, block: T.untyped).returns(T.untyped) }
|
||||
def conflicts_with(*args, &block); end
|
||||
|
||||
sig { params(args: T.untyped, block: T.untyped).returns(T.untyped) }
|
||||
def container(*args, &block); end
|
||||
|
||||
sig { params(args: T.untyped, block: T.untyped).returns(T.untyped) }
|
||||
def depends_on(*args, &block); end
|
||||
|
||||
sig { params(args: T.untyped, block: T.untyped).returns(T::Boolean) }
|
||||
def depends_on_set_in_block?(*args, &block); end
|
||||
|
||||
sig { params(args: T.untyped, block: T.untyped).returns(T.untyped) }
|
||||
def deprecate!(*args, &block); end
|
||||
|
||||
sig { params(args: T.untyped, block: T.untyped).returns(T::Boolean) }
|
||||
def deprecated?(*args, &block); end
|
||||
|
||||
sig { params(args: T.untyped, block: T.untyped).returns(T.untyped) }
|
||||
def deprecation_date(*args, &block); end
|
||||
|
||||
sig { params(args: T.untyped, block: T.untyped).returns(T.untyped) }
|
||||
def deprecation_reason(*args, &block); end
|
||||
|
||||
sig { params(args: T.untyped, block: T.untyped).returns(T.untyped) }
|
||||
def deprecation_replacement(*args, &block); end
|
||||
|
||||
sig { params(args: T.untyped, block: T.untyped).returns(T.untyped) }
|
||||
def desc(*args, &block); end
|
||||
|
||||
sig { params(args: T.untyped, block: T.untyped).returns(T.untyped) }
|
||||
def dictionary(*args, &block); end
|
||||
|
||||
sig { params(args: T.untyped, block: T.untyped).returns(T.untyped) }
|
||||
def disable!(*args, &block); end
|
||||
|
||||
sig { params(args: T.untyped, block: T.untyped).returns(T.untyped) }
|
||||
def disable_date(*args, &block); end
|
||||
|
||||
sig { params(args: T.untyped, block: T.untyped).returns(T.untyped) }
|
||||
def disable_reason(*args, &block); end
|
||||
|
||||
sig { params(args: T.untyped, block: T.untyped).returns(T.untyped) }
|
||||
def disable_replacement(*args, &block); end
|
||||
|
||||
sig { params(args: T.untyped, block: T.untyped).returns(T::Boolean) }
|
||||
def disabled?(*args, &block); end
|
||||
|
||||
sig { params(args: T.untyped, block: T.untyped).returns(T::Boolean) }
|
||||
def discontinued?(*args, &block); end
|
||||
|
||||
sig { params(args: T.untyped, block: T.untyped).returns(T.untyped) }
|
||||
def font(*args, &block); end
|
||||
|
||||
sig { params(args: T.untyped, block: T.untyped).returns(T.untyped) }
|
||||
def homepage(*args, &block); end
|
||||
|
||||
sig { params(args: T.untyped, block: T.untyped).returns(T.untyped) }
|
||||
def input_method(*args, &block); end
|
||||
|
||||
sig { params(args: T.untyped, block: T.untyped).returns(T.untyped) }
|
||||
def installer(*args, &block); end
|
||||
|
||||
sig { params(args: T.untyped, block: T.untyped).returns(T.untyped) }
|
||||
def internet_plugin(*args, &block); end
|
||||
|
||||
sig { params(args: T.untyped, block: T.untyped).returns(T.untyped) }
|
||||
def keyboard_layout(*args, &block); end
|
||||
|
||||
sig { params(args: T.untyped, block: T.untyped).returns(T.untyped) }
|
||||
def language(*args, &block); end
|
||||
|
||||
sig { params(args: T.untyped, block: T.untyped).returns(T.untyped) }
|
||||
def livecheck(*args, &block); end
|
||||
|
||||
sig { params(args: T.untyped, block: T.untyped).returns(T::Boolean) }
|
||||
def livecheck_defined?(*args, &block); end
|
||||
|
||||
sig { params(args: T.untyped, block: T.untyped).returns(T::Boolean) }
|
||||
def livecheckable?(*args, &block); end
|
||||
|
||||
sig { returns(T::Boolean) }
|
||||
def loaded_from_api?; end
|
||||
|
||||
sig { params(args: T.untyped, block: T.untyped).returns(T.untyped) }
|
||||
def manpage(*args, &block); end
|
||||
|
||||
sig { params(args: T.untyped, block: T.untyped).returns(T.untyped) }
|
||||
def mdimporter(*args, &block); end
|
||||
|
||||
sig { params(args: T.untyped, block: T.untyped).returns(T.untyped) }
|
||||
def name(*args, &block); end
|
||||
|
||||
sig { params(args: T.untyped, block: T.untyped).returns(T.nilable(MacOSVersion)) }
|
||||
def on_system_block_min_os(*args, &block); end
|
||||
|
||||
sig { params(args: T.untyped, block: T.untyped).returns(T::Boolean) }
|
||||
def on_system_blocks_exist?(*args, &block); end
|
||||
|
||||
sig { params(args: T.untyped, block: T.untyped).returns(T.untyped) }
|
||||
def pkg(*args, &block); end
|
||||
|
||||
sig { params(args: T.untyped, block: T.untyped).returns(T.untyped) }
|
||||
def postflight(*args, &block); end
|
||||
|
||||
sig { params(args: T.untyped, block: T.untyped).returns(T.untyped) }
|
||||
def preflight(*args, &block); end
|
||||
|
||||
sig { params(args: T.untyped, block: T.untyped).returns(T.untyped) }
|
||||
def prefpane(*args, &block); end
|
||||
|
||||
sig { params(args: T.untyped, block: T.untyped).returns(T.untyped) }
|
||||
def qlplugin(*args, &block); end
|
||||
|
||||
sig { params(args: T.untyped, block: T.untyped).returns(T.untyped) }
|
||||
def screen_saver(*args, &block); end
|
||||
|
||||
sig { params(args: T.untyped, block: T.untyped).returns(T.untyped) }
|
||||
def service(*args, &block); end
|
||||
|
||||
sig { params(args: T.untyped, block: T.untyped).returns(T.untyped) }
|
||||
def sha256(*args, &block); end
|
||||
|
||||
sig { params(args: T.untyped, block: T.untyped).returns(T.untyped) }
|
||||
def stage_only(*args, &block); end
|
||||
|
||||
sig { params(args: T.untyped, block: T.untyped).returns(T.untyped) }
|
||||
def staged_path(*args, &block); end
|
||||
|
||||
sig { params(args: T.untyped, block: T.untyped).returns(T.untyped) }
|
||||
def suite(*args, &block); end
|
||||
|
||||
sig { params(args: T.untyped, block: T.untyped).returns(T.untyped) }
|
||||
def uninstall(*args, &block); end
|
||||
|
||||
sig { params(args: T.untyped, block: T.untyped).returns(T.untyped) }
|
||||
def uninstall_postflight(*args, &block); end
|
||||
|
||||
sig { params(args: T.untyped, block: T.untyped).returns(T.untyped) }
|
||||
def uninstall_preflight(*args, &block); end
|
||||
|
||||
sig { params(args: T.untyped, block: T.untyped).returns(T.nilable(::Cask::URL)) }
|
||||
def url(*args, &block); end
|
||||
|
||||
sig { params(args: T.untyped, block: T.untyped).returns(T.untyped) }
|
||||
def version(*args, &block); end
|
||||
|
||||
sig { params(args: T.untyped, block: T.untyped).returns(T.untyped) }
|
||||
def vst3_plugin(*args, &block); end
|
||||
|
||||
sig { params(args: T.untyped, block: T.untyped).returns(T.untyped) }
|
||||
def vst_plugin(*args, &block); end
|
||||
|
||||
sig { params(args: T.untyped, block: T.untyped).returns(T.untyped) }
|
||||
def zap(*args, &block); end
|
||||
end
|
||||
|
@ -7,7 +7,7 @@ require "cask/url"
|
||||
module Tapioca
|
||||
module Compilers
|
||||
# A compiler for subclasses of Delegator.
|
||||
# To add a new delegator: require it above add add it to the DELEGATIONS hash below.
|
||||
# To add a new delegator: require it above and add it to the DELEGATIONS hash below.
|
||||
class Delegators < Tapioca::Dsl::Compiler
|
||||
# Mapping of delegator classes to the classes they delegate to (as defined in `__getobj__`).
|
||||
DELEGATIONS = T.let({
|
||||
|
@ -12,6 +12,13 @@ module Tapioca
|
||||
ARRAY_METHODS = T.let(["to_a", "to_ary"].freeze, T::Array[String])
|
||||
HASH_METHODS = T.let(["to_h", "to_hash"].freeze, T::Array[String])
|
||||
STRING_METHODS = T.let(["to_s", "to_str", "to_json"].freeze, T::Array[String])
|
||||
# Use this to override the default return type of a forwarded method:
|
||||
RETURN_TYPE_OVERRIDES = T.let({
|
||||
"::Cask::Cask" => {
|
||||
"on_system_block_min_os" => "T.nilable(MacOSVersion)",
|
||||
"url" => "T.nilable(::Cask::URL)",
|
||||
},
|
||||
}.freeze, T::Hash[String, T::Hash[String, String]])
|
||||
|
||||
ConstantType = type_member { { fixed: Module } }
|
||||
|
||||
@ -38,7 +45,7 @@ module Tapioca
|
||||
sig { params(klass: RBI::Scope, method: T.any(Method, UnboundMethod), class_method: T::Boolean).void }
|
||||
def compile_forwardable_method(klass, method, class_method: false)
|
||||
name = method.name.to_s
|
||||
return_type = return_type(name)
|
||||
return_type = return_type(klass.to_s, name)
|
||||
klass.create_method(
|
||||
name,
|
||||
parameters: [
|
||||
@ -50,16 +57,13 @@ module Tapioca
|
||||
)
|
||||
end
|
||||
|
||||
sig { params(name: String).returns(String) }
|
||||
def return_type(name)
|
||||
if name.end_with?("?")
|
||||
"T::Boolean"
|
||||
elsif ARRAY_METHODS.include?(name)
|
||||
"Array"
|
||||
elsif HASH_METHODS.include?(name)
|
||||
"Hash"
|
||||
elsif STRING_METHODS.include?(name)
|
||||
"String"
|
||||
sig { params(klass: String, name: String).returns(String) }
|
||||
def return_type(klass, name)
|
||||
if (override = RETURN_TYPE_OVERRIDES.dig(klass, name)) then override
|
||||
elsif name.end_with?("?") then "T::Boolean"
|
||||
elsif ARRAY_METHODS.include?(name) then "Array"
|
||||
elsif HASH_METHODS.include?(name) then "Hash"
|
||||
elsif STRING_METHODS.include?(name) then "String"
|
||||
else
|
||||
"T.untyped"
|
||||
end
|
||||
|
Loading…
x
Reference in New Issue
Block a user