Class: URL Private

Inherits:
Delegator
  • Object
show all
Extended by:
T::Sig
Defined in:
cask/url.rb

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.

Class corresponding to the url stanza.

Defined Under Namespace

Classes: BlockDSL, DSL

Instance Method Summary collapse

Constructor Details

#initialize(uri = nil, verified: nil, using: nil, tag: nil, branch: nil, revisions: nil, revision: nil, trust_cert: nil, cookies: nil, referer: nil, header: nil, user_agent: nil, data: nil, caller_location: T.must(caller_locations).fetch(0), dsl: nil, &block) ⇒ T.untyped

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:

  • uri (URI::Generic, String, nil) (defaults to: nil)
  • verified (String, nil) (defaults to: nil)
  • using (Symbol, nil) (defaults to: nil)
  • tag (String, nil) (defaults to: nil)
  • branch (String, nil) (defaults to: nil)
  • revisions (Array<String>, nil) (defaults to: nil)
  • revision (String, nil) (defaults to: nil)
  • trust_cert (Boolean, nil) (defaults to: nil)
  • cookies (Hash{String => String}, nil) (defaults to: nil)
  • referer (URI::Generic, String, nil) (defaults to: nil)
  • header (String, nil) (defaults to: nil)
  • user_agent (Symbol, String, nil) (defaults to: nil)
  • data (Hash{String => String}, nil) (defaults to: nil)
  • caller_location (Thread::Backtrace::Location) (defaults to: T.must(caller_locations).fetch(0))
  • dsl (Cask::DSL, nil) (defaults to: nil)
  • block (T.proc.params(arg0: T.all(String, BlockDSL::PageWithURL)).returns(T.untyped), nil)


164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
# File 'cask/url.rb', line 164

def initialize(
  uri = nil,
  verified: nil,
  using: nil,
  tag: nil,
  branch: nil,
  revisions: nil,
  revision: nil,
  trust_cert: nil,
  cookies: nil,
  referer: nil,
  header: nil,
  user_agent: nil,
  data: nil,
  caller_location: T.must(caller_locations).fetch(0),
  dsl: nil,
  &block
)
  super(
  if block
    LazyObject.new do
      *args = BlockDSL.new(uri, dsl: dsl, &block).call
      options = args.last.is_a?(Hash) ? args.pop : {}
      uri = T.let(args.first, T.any(URI::Generic, String))
      DSL.new(uri, **options)
    end
  else
    DSL.new(
      T.must(uri),
      verified:   verified,
      using:      using,
      tag:        tag,
      branch:     branch,
      revisions:  revisions,
      revision:   revision,
      trust_cert: trust_cert,
      cookies:    cookies,
      referer:    referer,
      header:     header,
      user_agent: user_agent,
      data:       data,
    )
  end
  )

  @from_block = !block.nil?
  @caller_location = caller_location
end

Instance Method Details

#__getobj__Object

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.



213
214
215
# File 'cask/url.rb', line 213

def __getobj__
  @dsl
end

#__setobj__(dsl) ⇒ Object

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.



217
218
219
# File 'cask/url.rb', line 217

def __setobj__(dsl)
  @dsl = dsl
end

#from_block?Boolean

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:

  • (Boolean)


244
245
246
# File 'cask/url.rb', line 244

def from_block?
  @from_block
end

#unversioned?(ignore_major_version: false) ⇒ Boolean

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:

  • ignore_major_version (Boolean) (defaults to: false)

Returns:

  • (Boolean)


233
234
235
236
237
238
239
240
241
# File 'cask/url.rb', line 233

def unversioned?(ignore_major_version: false)
  interpolated_url = raw_interpolated_url

  return false unless interpolated_url

  interpolated_url = interpolated_url.gsub(/\#{\s*version\s*\.major\s*}/, "") if ignore_major_version

  interpolated_url.exclude?('#{')
end