Class GitHub::Api
In: lib/git_hub/api.rb
Parent: Object

Methods

Included Modules

Singleton

Attributes

auth  [W] 

Public Instance methods

[Source]

# File lib/git_hub/api.rb, line 10
    def auth
      @auth || {}
    end

[Source]

# File lib/git_hub/api.rb, line 14
    def authenticated?
      auth != {}
    end

Turns string into appropriate class constant, returns nil if class not found

[Source]

# 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

[Source]

# 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

[Validate]