5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
# File 'lib/gems/connection.rb', line 5
def connection(format=format)
options = {
:headers => {
'User-Agent' => user_agent,
},
:ssl => {:verify => false},
:url => 'https://rubygems.org',
}
Faraday.new(options) do |connection|
connection.use Faraday::Request::UrlEncoded
connection.use Faraday::Response::RaiseError
connection.use Faraday::Response::Mashify
case format.to_sym
when :json
connection.use Faraday::Response::ParseJson
when :marshal
connection.use Faraday::Response::ParseMarshal
when :xml
connection.use Faraday::Response::ParseXml
end
connection.adapter Faraday.default_adapter
end
end
|