aboutsummaryrefslogtreecommitdiffstats
path: root/Library/Homebrew/cask/lib/hbc/url.rb
blob: 8c652657b617559174207e4533bb06c90e9e898b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
module Hbc
  class URL
    attr_reader :using, :revision, :trust_cert, :uri, :cookies, :referer, :data, :user_agent

    extend Forwardable
    def_delegators :uri, :path, :scheme, :to_s

    def self.from(*args, &block)
      if block_given?
        Hbc::DSL::StanzaProxy.once(self) { new(*block.call) }
      else
        new(*args)
      end
    end

    def initialize(uri, options = {})
      @uri        = Hbc::UnderscoreSupportingURI.parse(uri)
      @user_agent = options.fetch(:user_agent, :default)
      @cookies    = options[:cookies]
      @referer    = options[:referer]
      @using      = options[:using]
      @revision   = options[:revision]
      @trust_cert = options[:trust_cert]
      @data       = options[:data]
    end
  end
end