mirror of
https://github.com/Homebrew/brew.git
synced 2025-07-14 16:09:03 +08:00
30 lines
577 B
Ruby
30 lines
577 B
Ruby
# frozen_string_literal: true
|
|
|
|
class URL
|
|
ATTRIBUTES = [
|
|
:using,
|
|
:tag, :branch, :revisions, :revision,
|
|
:trust_cert, :cookies, :referer, :user_agent,
|
|
:data
|
|
].freeze
|
|
|
|
attr_reader :uri, :specs
|
|
attr_reader(*ATTRIBUTES)
|
|
|
|
extend Forwardable
|
|
def_delegators :uri, :path, :scheme, :to_s
|
|
|
|
def initialize(uri, **options)
|
|
@uri = URI(uri)
|
|
@user_agent = :default
|
|
|
|
ATTRIBUTES.each do |attribute|
|
|
next unless options.key?(attribute)
|
|
|
|
instance_variable_set("@#{attribute}", options[attribute])
|
|
end
|
|
|
|
@specs = options
|
|
end
|
|
end
|