2025-03-12 19:05:01 -07:00
|
|
|
# typed: strict
|
2019-04-19 15:38:03 +09:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2023-05-19 19:43:15 +02:00
|
|
|
require "source_location"
|
2023-09-06 09:55:17 -04:00
|
|
|
require "utils/curl"
|
2023-05-19 19:43:15 +02:00
|
|
|
|
2023-04-18 00:22:13 +01:00
|
|
|
module Cask
|
|
|
|
# Class corresponding to the `url` stanza.
|
2024-10-14 10:50:57 -07:00
|
|
|
class URL < SimpleDelegator
|
2025-03-13 10:26:41 -07:00
|
|
|
BlockReturn = T.type_alias do
|
|
|
|
T.any(URI::Generic, String, [T.any(URI::Generic, String), T::Hash[Symbol, T.untyped]])
|
|
|
|
end
|
|
|
|
|
2023-04-18 00:22:13 +01:00
|
|
|
class DSL
|
2025-03-12 19:05:01 -07:00
|
|
|
sig { returns(T.any(URI::Generic, String)) }
|
|
|
|
attr_reader :uri
|
|
|
|
|
|
|
|
sig { returns(T.nilable(T::Array[String])) }
|
|
|
|
attr_reader :revisions
|
|
|
|
|
|
|
|
sig { returns(T.nilable(T::Boolean)) }
|
|
|
|
attr_reader :trust_cert
|
|
|
|
|
|
|
|
sig { returns(T.nilable(T::Hash[String, String])) }
|
|
|
|
attr_reader :cookies, :data
|
|
|
|
|
|
|
|
sig { returns(T.nilable(T.any(String, T::Array[String]))) }
|
|
|
|
attr_reader :header
|
2024-10-05 18:56:38 -07:00
|
|
|
|
|
|
|
sig { returns(T.nilable(T.any(URI::Generic, String))) }
|
|
|
|
attr_reader :referer
|
|
|
|
|
|
|
|
sig { returns(T::Hash[Symbol, T.untyped]) }
|
|
|
|
attr_reader :specs
|
|
|
|
|
|
|
|
sig { returns(T.nilable(T.any(Symbol, String))) }
|
|
|
|
attr_reader :user_agent
|
|
|
|
|
2025-03-12 11:39:01 -07:00
|
|
|
sig { returns(T.any(T::Class[AbstractDownloadStrategy], Symbol, NilClass)) }
|
2024-10-05 18:56:38 -07:00
|
|
|
attr_reader :using
|
|
|
|
|
|
|
|
sig { returns(T.nilable(String)) }
|
2025-03-12 19:05:01 -07:00
|
|
|
attr_reader :tag, :branch, :revision, :only_path, :verified
|
2023-04-18 00:22:13 +01:00
|
|
|
|
|
|
|
extend Forwardable
|
|
|
|
def_delegators :uri, :path, :scheme, :to_s
|
2021-03-31 06:14:41 +02:00
|
|
|
|
2023-04-18 00:22:13 +01:00
|
|
|
sig {
|
|
|
|
params(
|
|
|
|
uri: T.any(URI::Generic, String),
|
2024-04-26 20:55:51 +02:00
|
|
|
# @api public
|
2023-04-18 00:22:13 +01:00
|
|
|
verified: T.nilable(String),
|
2024-04-26 20:55:51 +02:00
|
|
|
# @api public
|
2025-03-12 11:39:01 -07:00
|
|
|
using: T.any(T::Class[AbstractDownloadStrategy], Symbol, NilClass),
|
2024-04-26 20:55:51 +02:00
|
|
|
# @api public
|
2023-04-18 00:22:13 +01:00
|
|
|
tag: T.nilable(String),
|
2024-04-26 20:55:51 +02:00
|
|
|
# @api public
|
2023-04-18 00:22:13 +01:00
|
|
|
branch: T.nilable(String),
|
2024-04-26 20:55:51 +02:00
|
|
|
# @api public
|
2023-04-18 00:22:13 +01:00
|
|
|
revisions: T.nilable(T::Array[String]),
|
2024-04-26 20:55:51 +02:00
|
|
|
# @api public
|
2023-04-18 00:22:13 +01:00
|
|
|
revision: T.nilable(String),
|
2024-04-26 20:55:51 +02:00
|
|
|
# @api public
|
2023-04-18 00:22:13 +01:00
|
|
|
trust_cert: T.nilable(T::Boolean),
|
2024-04-26 20:55:51 +02:00
|
|
|
# @api public
|
2023-04-18 00:22:13 +01:00
|
|
|
cookies: T.nilable(T::Hash[String, String]),
|
|
|
|
referer: T.nilable(T.any(URI::Generic, String)),
|
2024-04-26 20:55:51 +02:00
|
|
|
# @api public
|
2023-06-27 09:37:22 -04:00
|
|
|
header: T.nilable(T.any(String, T::Array[String])),
|
2023-04-18 00:22:13 +01:00
|
|
|
user_agent: T.nilable(T.any(Symbol, String)),
|
2024-04-26 20:55:51 +02:00
|
|
|
# @api public
|
2023-04-18 00:22:13 +01:00
|
|
|
data: T.nilable(T::Hash[String, String]),
|
2024-04-26 20:55:51 +02:00
|
|
|
# @api public
|
2023-04-18 00:22:13 +01:00
|
|
|
only_path: T.nilable(String),
|
|
|
|
).void
|
|
|
|
}
|
|
|
|
def initialize(
|
2025-03-12 19:05:01 -07:00
|
|
|
uri, 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, only_path: nil
|
2023-04-18 00:22:13 +01:00
|
|
|
)
|
2025-03-12 19:05:01 -07:00
|
|
|
@uri = T.let(URI(uri), T.any(URI::Generic, String))
|
2023-04-18 00:22:13 +01:00
|
|
|
|
2023-06-28 09:11:14 -04:00
|
|
|
header = Array(header) unless header.nil?
|
|
|
|
|
2023-04-18 00:22:13 +01:00
|
|
|
specs = {}
|
2025-03-12 19:05:01 -07:00
|
|
|
specs[:verified] = @verified = T.let(verified, T.nilable(String))
|
|
|
|
specs[:using] = @using = T.let(using, T.any(T::Class[AbstractDownloadStrategy], Symbol, NilClass))
|
|
|
|
specs[:tag] = @tag = T.let(tag, T.nilable(String))
|
|
|
|
specs[:branch] = @branch = T.let(branch, T.nilable(String))
|
|
|
|
specs[:revisions] = @revisions = T.let(revisions, T.nilable(T::Array[String]))
|
|
|
|
specs[:revision] = @revision = T.let(revision, T.nilable(String))
|
|
|
|
specs[:trust_cert] = @trust_cert = T.let(trust_cert, T.nilable(T::Boolean))
|
|
|
|
specs[:cookies] = @cookies = T.let(cookies, T.nilable(T::Hash[String, String]))
|
|
|
|
specs[:referer] = @referer = T.let(referer, T.nilable(T.any(URI::Generic, String)))
|
|
|
|
specs[:headers] = @header = T.let(header, T.nilable(T.any(String, T::Array[String])))
|
|
|
|
specs[:user_agent] = @user_agent = T.let(user_agent || :default, T.nilable(T.any(Symbol, String)))
|
|
|
|
specs[:data] = @data = T.let(data, T.nilable(T::Hash[String, String]))
|
|
|
|
specs[:only_path] = @only_path = T.let(only_path, T.nilable(String))
|
|
|
|
|
|
|
|
@specs = T.let(specs.compact, T::Hash[Symbol, T.untyped])
|
2023-04-18 00:22:13 +01:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
class BlockDSL
|
2024-04-26 20:55:51 +02:00
|
|
|
# Allow accessing the URL associated with page contents.
|
Curl: use `typed: strict`
This upgrades `utils/curl.rb` to `typed: strict`, which requires
a number of changes to pass `brew typecheck`. The most
straightforward are adding type signatures to methods, adding type
annotations (e.g., `T.let`) to variables that need them, and ensuring
that methods always use the expected return type.
I had to refactor areas where we call a `Utils::Curl` method and use
array destructuring on a `SystemCommand::Result` return value
(e.g., `output, errors, status = curl_output(...)`), as Sorbet
doesn't understand implicit array conversion. As suggested by Markus,
I've switched these areas to use `#stdout`, `#stderr`, and `#status`.
This requires the use of an intermediate variable (`result`) in some
cases but this was a fairly straightforward substitution.
I also had to refactor how `Cask::URL::BlockDSL::PageWithURL` works.
It currently uses `page.extend PageWithURL` to add a `url` attribute
but this reworks it to subclass `SimpleDelegator` and use an
`initialize` method instead. This achieves the same goal but in a way
that Sorbet can understand.
2025-01-10 21:37:20 -05:00
|
|
|
class PageWithURL < SimpleDelegator
|
2024-04-26 20:55:51 +02:00
|
|
|
# Get the URL of the fetched page.
|
|
|
|
#
|
|
|
|
# ### Example
|
|
|
|
#
|
|
|
|
# ```ruby
|
|
|
|
# url "https://example.org/download" do |page|
|
Curl: use `typed: strict`
This upgrades `utils/curl.rb` to `typed: strict`, which requires
a number of changes to pass `brew typecheck`. The most
straightforward are adding type signatures to methods, adding type
annotations (e.g., `T.let`) to variables that need them, and ensuring
that methods always use the expected return type.
I had to refactor areas where we call a `Utils::Curl` method and use
array destructuring on a `SystemCommand::Result` return value
(e.g., `output, errors, status = curl_output(...)`), as Sorbet
doesn't understand implicit array conversion. As suggested by Markus,
I've switched these areas to use `#stdout`, `#stderr`, and `#status`.
This requires the use of an intermediate variable (`result`) in some
cases but this was a fairly straightforward substitution.
I also had to refactor how `Cask::URL::BlockDSL::PageWithURL` works.
It currently uses `page.extend PageWithURL` to add a `url` attribute
but this reworks it to subclass `SimpleDelegator` and use an
`initialize` method instead. This achieves the same goal but in a way
that Sorbet can understand.
2025-01-10 21:37:20 -05:00
|
|
|
# file_path = page[/href="([^"]+\.dmg)"/, 1]
|
|
|
|
# URI.join(page.url, file_path)
|
2024-04-26 20:55:51 +02:00
|
|
|
# end
|
|
|
|
# ```
|
|
|
|
#
|
2023-04-18 00:22:13 +01:00
|
|
|
# @api public
|
|
|
|
sig { returns(URI::Generic) }
|
|
|
|
attr_accessor :url
|
Curl: use `typed: strict`
This upgrades `utils/curl.rb` to `typed: strict`, which requires
a number of changes to pass `brew typecheck`. The most
straightforward are adding type signatures to methods, adding type
annotations (e.g., `T.let`) to variables that need them, and ensuring
that methods always use the expected return type.
I had to refactor areas where we call a `Utils::Curl` method and use
array destructuring on a `SystemCommand::Result` return value
(e.g., `output, errors, status = curl_output(...)`), as Sorbet
doesn't understand implicit array conversion. As suggested by Markus,
I've switched these areas to use `#stdout`, `#stderr`, and `#status`.
This requires the use of an intermediate variable (`result`) in some
cases but this was a fairly straightforward substitution.
I also had to refactor how `Cask::URL::BlockDSL::PageWithURL` works.
It currently uses `page.extend PageWithURL` to add a `url` attribute
but this reworks it to subclass `SimpleDelegator` and use an
`initialize` method instead. This achieves the same goal but in a way
that Sorbet can understand.
2025-01-10 21:37:20 -05:00
|
|
|
|
2025-03-12 19:05:01 -07:00
|
|
|
sig { params(str: String, url: URI::Generic).void }
|
Curl: use `typed: strict`
This upgrades `utils/curl.rb` to `typed: strict`, which requires
a number of changes to pass `brew typecheck`. The most
straightforward are adding type signatures to methods, adding type
annotations (e.g., `T.let`) to variables that need them, and ensuring
that methods always use the expected return type.
I had to refactor areas where we call a `Utils::Curl` method and use
array destructuring on a `SystemCommand::Result` return value
(e.g., `output, errors, status = curl_output(...)`), as Sorbet
doesn't understand implicit array conversion. As suggested by Markus,
I've switched these areas to use `#stdout`, `#stderr`, and `#status`.
This requires the use of an intermediate variable (`result`) in some
cases but this was a fairly straightforward substitution.
I also had to refactor how `Cask::URL::BlockDSL::PageWithURL` works.
It currently uses `page.extend PageWithURL` to add a `url` attribute
but this reworks it to subclass `SimpleDelegator` and use an
`initialize` method instead. This achieves the same goal but in a way
that Sorbet can understand.
2025-01-10 21:37:20 -05:00
|
|
|
def initialize(str, url)
|
|
|
|
super(str)
|
2025-03-12 19:05:01 -07:00
|
|
|
@url = T.let(url, URI::Generic)
|
Curl: use `typed: strict`
This upgrades `utils/curl.rb` to `typed: strict`, which requires
a number of changes to pass `brew typecheck`. The most
straightforward are adding type signatures to methods, adding type
annotations (e.g., `T.let`) to variables that need them, and ensuring
that methods always use the expected return type.
I had to refactor areas where we call a `Utils::Curl` method and use
array destructuring on a `SystemCommand::Result` return value
(e.g., `output, errors, status = curl_output(...)`), as Sorbet
doesn't understand implicit array conversion. As suggested by Markus,
I've switched these areas to use `#stdout`, `#stderr`, and `#status`.
This requires the use of an intermediate variable (`result`) in some
cases but this was a fairly straightforward substitution.
I also had to refactor how `Cask::URL::BlockDSL::PageWithURL` works.
It currently uses `page.extend PageWithURL` to add a `url` attribute
but this reworks it to subclass `SimpleDelegator` and use an
`initialize` method instead. This achieves the same goal but in a way
that Sorbet can understand.
2025-01-10 21:37:20 -05:00
|
|
|
end
|
2023-04-18 00:22:13 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
sig {
|
|
|
|
params(
|
|
|
|
uri: T.nilable(T.any(URI::Generic, String)),
|
2024-04-26 20:55:51 +02:00
|
|
|
dsl: ::Cask::DSL,
|
2025-03-12 19:05:01 -07:00
|
|
|
block: T.proc.params(arg0: T.all(String, PageWithURL)).returns(BlockReturn),
|
2023-04-18 00:22:13 +01:00
|
|
|
).void
|
|
|
|
}
|
2024-04-26 20:55:51 +02:00
|
|
|
def initialize(uri, dsl:, &block)
|
2025-03-12 19:05:01 -07:00
|
|
|
@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))
|
2024-09-25 09:59:36 +01:00
|
|
|
|
|
|
|
odeprecated "cask `url do` blocks" if @block
|
2023-04-18 00:22:13 +01:00
|
|
|
end
|
|
|
|
|
2025-03-12 19:05:01 -07:00
|
|
|
sig { returns(BlockReturn) }
|
2023-04-18 00:22:13 +01:00
|
|
|
def call
|
|
|
|
if @uri
|
Curl: use `typed: strict`
This upgrades `utils/curl.rb` to `typed: strict`, which requires
a number of changes to pass `brew typecheck`. The most
straightforward are adding type signatures to methods, adding type
annotations (e.g., `T.let`) to variables that need them, and ensuring
that methods always use the expected return type.
I had to refactor areas where we call a `Utils::Curl` method and use
array destructuring on a `SystemCommand::Result` return value
(e.g., `output, errors, status = curl_output(...)`), as Sorbet
doesn't understand implicit array conversion. As suggested by Markus,
I've switched these areas to use `#stdout`, `#stderr`, and `#status`.
This requires the use of an intermediate variable (`result`) in some
cases but this was a fairly straightforward substitution.
I also had to refactor how `Cask::URL::BlockDSL::PageWithURL` works.
It currently uses `page.extend PageWithURL` to add a `url` attribute
but this reworks it to subclass `SimpleDelegator` and use an
`initialize` method instead. This achieves the same goal but in a way
that Sorbet can understand.
2025-01-10 21:37:20 -05:00
|
|
|
result = ::Utils::Curl.curl_output("--fail", "--silent", "--location", @uri.to_s)
|
2023-04-18 00:22:13 +01:00
|
|
|
result.assert_success!
|
|
|
|
|
Curl: use `typed: strict`
This upgrades `utils/curl.rb` to `typed: strict`, which requires
a number of changes to pass `brew typecheck`. The most
straightforward are adding type signatures to methods, adding type
annotations (e.g., `T.let`) to variables that need them, and ensuring
that methods always use the expected return type.
I had to refactor areas where we call a `Utils::Curl` method and use
array destructuring on a `SystemCommand::Result` return value
(e.g., `output, errors, status = curl_output(...)`), as Sorbet
doesn't understand implicit array conversion. As suggested by Markus,
I've switched these areas to use `#stdout`, `#stderr`, and `#status`.
This requires the use of an intermediate variable (`result`) in some
cases but this was a fairly straightforward substitution.
I also had to refactor how `Cask::URL::BlockDSL::PageWithURL` works.
It currently uses `page.extend PageWithURL` to add a `url` attribute
but this reworks it to subclass `SimpleDelegator` and use an
`initialize` method instead. This achieves the same goal but in a way
that Sorbet can understand.
2025-01-10 21:37:20 -05:00
|
|
|
page = PageWithURL.new(result.stdout, URI(@uri))
|
2023-04-18 00:22:13 +01:00
|
|
|
instance_exec(page, &@block)
|
|
|
|
else
|
|
|
|
instance_exec(&@block)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2024-10-05 18:56:38 -07:00
|
|
|
private
|
|
|
|
|
2024-04-26 20:55:51 +02:00
|
|
|
# Allows calling a nested `url` stanza in a `url do` block.
|
|
|
|
#
|
2023-04-18 00:22:13 +01:00
|
|
|
# @api public
|
|
|
|
sig {
|
|
|
|
params(
|
|
|
|
uri: T.any(URI::Generic, String),
|
2025-03-12 19:05:01 -07:00
|
|
|
block: T.proc.params(arg0: T.all(String, PageWithURL)).returns(BlockReturn),
|
|
|
|
).returns(BlockReturn)
|
2023-04-18 00:22:13 +01:00
|
|
|
}
|
|
|
|
def url(uri, &block)
|
2024-04-26 20:55:51 +02:00
|
|
|
self.class.new(uri, dsl: @dsl, &block).call
|
2023-04-18 00:22:13 +01:00
|
|
|
end
|
|
|
|
|
2024-04-26 20:55:51 +02:00
|
|
|
# This allows calling DSL methods from inside a `url` block.
|
|
|
|
#
|
2023-04-18 00:22:13 +01:00
|
|
|
# @api public
|
2025-03-12 19:05:01 -07:00
|
|
|
sig {
|
2025-03-13 10:26:41 -07:00
|
|
|
override.params(method: Symbol, args: T.untyped, block: T.nilable(T.proc.returns(T.untyped)))
|
|
|
|
.returns(T.anything)
|
2025-03-12 19:05:01 -07:00
|
|
|
}
|
2023-04-18 00:22:13 +01:00
|
|
|
def method_missing(method, *args, &block)
|
|
|
|
if @dsl.respond_to?(method)
|
2024-08-18 16:28:17 -07:00
|
|
|
@dsl.public_send(method, *args, &block)
|
2023-04-18 00:22:13 +01:00
|
|
|
else
|
|
|
|
super
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2025-03-12 19:05:01 -07:00
|
|
|
sig { override.params(method_name: T.any(Symbol, String), include_private: T::Boolean).returns(T::Boolean) }
|
|
|
|
def respond_to_missing?(method_name, include_private = false)
|
|
|
|
@dsl.respond_to?(method_name, include_private) || super
|
2023-04-18 00:22:13 +01:00
|
|
|
end
|
|
|
|
end
|
2021-03-31 06:14:41 +02:00
|
|
|
|
|
|
|
sig {
|
|
|
|
params(
|
2023-04-18 00:22:13 +01:00
|
|
|
uri: T.nilable(T.any(URI::Generic, String)),
|
|
|
|
verified: T.nilable(String),
|
2025-03-12 11:39:01 -07:00
|
|
|
using: T.any(T::Class[AbstractDownloadStrategy], Symbol, NilClass),
|
2023-04-18 00:22:13 +01:00
|
|
|
tag: T.nilable(String),
|
|
|
|
branch: T.nilable(String),
|
|
|
|
revisions: T.nilable(T::Array[String]),
|
|
|
|
revision: T.nilable(String),
|
|
|
|
trust_cert: T.nilable(T::Boolean),
|
|
|
|
cookies: T.nilable(T::Hash[String, String]),
|
|
|
|
referer: T.nilable(T.any(URI::Generic, String)),
|
2023-11-09 10:23:13 +11:00
|
|
|
header: T.nilable(T.any(String, T::Array[String])),
|
2023-04-18 00:22:13 +01:00
|
|
|
user_agent: T.nilable(T.any(Symbol, String)),
|
|
|
|
data: T.nilable(T::Hash[String, String]),
|
|
|
|
only_path: T.nilable(String),
|
|
|
|
caller_location: Thread::Backtrace::Location,
|
|
|
|
dsl: T.nilable(::Cask::DSL),
|
2025-03-12 19:05:01 -07:00
|
|
|
block: T.nilable(T.proc.params(arg0: T.all(String, BlockDSL::PageWithURL)).returns(BlockReturn)),
|
2021-03-31 06:14:41 +02:00
|
|
|
).void
|
|
|
|
}
|
|
|
|
def initialize(
|
2025-03-12 19:05:01 -07:00
|
|
|
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, only_path: nil,
|
|
|
|
caller_location: caller_locations.fetch(0), dsl: nil, &block
|
2021-03-31 06:14:41 +02:00
|
|
|
)
|
2023-04-18 00:22:13 +01:00
|
|
|
super(
|
|
|
|
if block
|
|
|
|
LazyObject.new do
|
2024-04-26 20:55:51 +02:00
|
|
|
uri2, options = *BlockDSL.new(uri, dsl: T.must(dsl), &block).call
|
2023-04-29 03:09:50 +02:00
|
|
|
options ||= {}
|
|
|
|
DSL.new(uri2, **options)
|
2023-04-18 00:22:13 +01:00
|
|
|
end
|
|
|
|
else
|
2025-03-12 19:05:01 -07:00
|
|
|
DSL.new(T.must(uri), verified:, using:, tag:, branch:, revisions:, revision:, trust_cert:, cookies:,
|
|
|
|
referer:, header:, user_agent:, data:, only_path:)
|
2023-04-18 00:22:13 +01:00
|
|
|
end
|
|
|
|
)
|
2021-03-31 06:14:41 +02:00
|
|
|
|
2025-03-12 19:05:01 -07:00
|
|
|
@from_block = T.let(!block.nil?, T::Boolean)
|
|
|
|
@caller_location = T.let(caller_location, Thread::Backtrace::Location)
|
2021-03-31 06:14:41 +02:00
|
|
|
end
|
|
|
|
|
2023-05-19 19:43:15 +02:00
|
|
|
sig { returns(Homebrew::SourceLocation) }
|
|
|
|
def location
|
|
|
|
Homebrew::SourceLocation.new(@caller_location.lineno, raw_url_line&.index("url"))
|
|
|
|
end
|
|
|
|
|
2023-04-18 00:22:13 +01:00
|
|
|
sig { params(ignore_major_version: T::Boolean).returns(T::Boolean) }
|
|
|
|
def unversioned?(ignore_major_version: false)
|
2023-05-19 19:43:15 +02:00
|
|
|
interpolated_url = raw_url_line&.then { |line| line[/url\s+"([^"]+)"/, 1] }
|
2021-03-31 06:14:41 +02:00
|
|
|
|
2023-04-18 00:22:13 +01:00
|
|
|
return false unless interpolated_url
|
2016-08-18 22:11:42 +03:00
|
|
|
|
2025-02-10 16:15:33 +09:00
|
|
|
interpolated_url = interpolated_url.gsub(/\#{\s*arch\s*}/, "")
|
2023-04-18 00:22:13 +01:00
|
|
|
interpolated_url = interpolated_url.gsub(/\#{\s*version\s*\.major\s*}/, "") if ignore_major_version
|
2020-12-07 18:46:35 +01:00
|
|
|
|
2023-04-18 00:22:13 +01:00
|
|
|
interpolated_url.exclude?('#{')
|
|
|
|
end
|
2020-12-12 06:01:26 +01:00
|
|
|
|
2023-04-18 00:22:13 +01:00
|
|
|
sig { returns(T::Boolean) }
|
|
|
|
def from_block?
|
|
|
|
@from_block
|
|
|
|
end
|
2024-10-05 18:56:38 -07:00
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
sig { returns(T.nilable(String)) }
|
|
|
|
def raw_url_line
|
|
|
|
return @raw_url_line if defined?(@raw_url_line)
|
|
|
|
|
2025-03-12 19:05:01 -07:00
|
|
|
@raw_url_line = T.let(Pathname(T.must(@caller_location.path))
|
2024-10-05 18:56:38 -07:00
|
|
|
.each_line
|
|
|
|
.drop(@caller_location.lineno - 1)
|
2025-03-12 19:05:01 -07:00
|
|
|
.first, T.nilable(String))
|
2024-10-05 18:56:38 -07:00
|
|
|
end
|
2020-12-12 06:01:26 +01:00
|
|
|
end
|
2016-08-18 22:11:42 +03:00
|
|
|
end
|