Class | GitHub::Api |
In: |
lib/git_hub/api.rb
|
Parent: | Object |
auth | [W] |
Turns string into appropriate class constant, returns nil if class not found
# File lib/git_hub/api.rb, line 19 def classify name klass = name.split("::").inject(Kernel) {|klass, const_name| klass.const_get const_name } klass.is_a?(Class) ? klass : nil rescue NameError nil end
# File lib/git_hub/api.rb, line 26 def request verb, url, params = {} method = classify('Net::HTTP::' + verb.to_s.capitalize) uri = URI.parse url server = Net::HTTP.new(uri.host, uri.port) server.use_ssl = (uri.scheme == 'https') server.verify_mode = OpenSSL::SSL::VERIFY_NONE if server.use_ssl? server.start do |http| req = method.new(uri.path) req.form_data = params.merge(auth) http.request(req) end end