Sha256: f42e43c39bb7aa2b034e59daebe26b3a8c4571a7bd4ef89b26e2eab4eab855ad
Contents?: true
Size: 975 Bytes
Versions: 3
Compression:
Stored size: 975 Bytes
Contents
require 'net/https' require 'singleton' module GitHub class Api include Singleton attr_writer :auth def auth @auth || {} end def authenticated? auth != {} end # Turns string into appropriate class constant, returns nil if class not found 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 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 end end
Version data entries
3 entries across 3 versions & 2 rubygems
Version | Path |
---|---|
git_hub-0.1.0 | lib/git_hub/api.rb |
zemax-0.1.0 | lib/git_hub/api.rb |
git_hub-0.0.1 | lib/git_hub/api.rb |