2018-07-30 19:48:20 +02:00
|
|
|
class URL
|
|
|
|
ATTRIBUTES = [
|
|
|
|
:using,
|
|
|
|
:tag, :branch, :revisions, :revision,
|
|
|
|
:trust_cert, :cookies, :referer, :user_agent,
|
|
|
|
:data
|
|
|
|
].freeze
|
2016-08-18 22:11:42 +03:00
|
|
|
|
2018-07-30 19:48:20 +02:00
|
|
|
attr_reader :uri
|
|
|
|
attr_reader(*ATTRIBUTES)
|
2016-08-18 22:11:42 +03:00
|
|
|
|
2018-07-30 19:48:20 +02:00
|
|
|
extend Forwardable
|
|
|
|
def_delegators :uri, :path, :scheme, :to_s
|
2016-08-18 22:11:42 +03:00
|
|
|
|
2018-07-30 19:48:20 +02:00
|
|
|
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])
|
2016-09-24 13:52:43 +02:00
|
|
|
end
|
2016-08-18 22:11:42 +03:00
|
|
|
end
|
|
|
|
end
|