Class: Cask::URL::BlockDSL Private
Overview
This class is part of a private API. This class may only be used in the Homebrew/brew repository. Third parties should avoid using this class if possible, as it may be removed or changed without warning.
Allow passing a block to the url
stanza.
Defined Under Namespace
Classes: PageWithURL
Instance Method Summary collapse
- #call ⇒ BlockReturn private
- #initialize(uri, dsl:, &block) ⇒ void constructor private
Constructor Details
#initialize(uri, dsl:, &block) ⇒ void
This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.
138 139 140 141 142 143 144 |
# File 'cask/url.rb', line 138 def initialize(uri, dsl:, &block) @uri = T.let(uri, T.nilable(T.any(URI::Generic, String))) @dsl = T.let(dsl, ::Cask::DSL) @block = T.let(block, T.proc.params(arg0: T.all(String, PageWithURL)).returns(BlockReturn)) odisabled "cask `url do` blocks" if @block end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args, &block) ⇒ T.anything (private)
This allows calling DSL methods from inside a url
block.
181 182 183 184 185 186 187 |
# File 'cask/url.rb', line 181 def method_missing(method, *args, &block) if @dsl.respond_to?(method) @dsl.public_send(method, *args, &block) else super end end |
Instance Method Details
#call ⇒ BlockReturn
This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.
147 148 149 150 151 152 153 154 155 156 157 |
# File 'cask/url.rb', line 147 def call if @uri result = ::Utils::Curl.curl_output("--fail", "--silent", "--location", @uri.to_s) result.assert_success! page = PageWithURL.new(result.stdout, URI(@uri)) instance_exec(page, &@block) else instance_exec(&@block) end end |