homebrew-cask-versions/lib/cask/url.rb
Pedro Silva e58f3f89ca add new CurlPostDownloadStrategy
- lib/cask/url.rb: initialize(): add new `:data` attribute to hold post parameters
- lib/cask/download.rb: perform(): dispatch to new class based on `:using => :post`
- lib/cask/download_strategy.rb: Cask::CurlPostDownloadStrategy:
  			extend curl_args with x-www-form-urlencoded data
- doc/CASK_LANGUAGE_REFERENCE.md: HTTP URLs: document new strategy
- test/cask/test_download_strategy.rb: Cask::CurlPostDownloadStrategy: test new strategy
2014-03-07 20:51:35 +01:00

29 lines
694 B
Ruby

require 'forwardable'
class Cask::URL
FAKE_USER_AGENT = 'Chrome/32.0.1000.00'
attr_reader :using, :revision, :trust_cert, :uri, :cookies, :referer, :data
extend Forwardable
def_delegators :uri, :path, :scheme, :to_s
def initialize(uri, options={})
@uri = Cask::UnderscoreSupportingURI.parse(uri)
@user_agent = options[:user_agent]
@cookies = options[:cookies]
@referer = options[:referer]
@using = options[:using]
@revision = options[:revision]
@trust_cert = options[:trust_cert]
@data = options[:data]
end
def user_agent
if @user_agent == :fake
FAKE_USER_AGENT
else
@user_agent
end
end
end