Make FromContentLoader.try_new typesafe

This commit is contained in:
Douglas Eichelberger 2024-08-11 16:19:51 -07:00
parent d40e1707f2
commit a41f15ede7

View File

@ -51,10 +51,14 @@ module Cask
# Loads a cask from a string.
class FromContentLoader < AbstractContentLoader
sig {
params(ref: T.any(Pathname, String, URI::Generic), warn: T::Boolean)
.returns(T.nilable(T.attached_class))
}
def self.try_new(ref, warn: false)
return false unless ref.respond_to?(:to_str)
return if ref.is_a?(URI::Generic)
content = T.unsafe(ref).to_str
content = ref.to_str
# Cache compiled regex
@regex ||= begin