Class: Cask::URL::BlockDSL Private

Inherits:
Object show all
Defined in:
cask/url.rb

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.

Defined Under Namespace

Classes: PageWithURL

Instance Method Summary collapse

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.

Parameters:



132
133
134
135
136
137
138
# File 'cask/url.rb', line 132

def initialize(uri, dsl:, &block)
  @uri = uri
  @dsl = dsl
  @block = block

  odeprecated "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) ⇒ Object (private)

This allows calling DSL methods from inside a url block.



172
173
174
175
176
177
178
# File 'cask/url.rb', line 172

def method_missing(method, *args, &block)
  if @dsl.respond_to?(method)
    @dsl.public_send(method, *args, &block)
  else
    super
  end
end

Instance Method Details

#callURI::Generic, ...

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.

Returns:



141
142
143
144
145
146
147
148
149
150
151
# File 'cask/url.rb', line 141

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