Class: GitHub::Browser

Inherits:
Object
  • Object
show all
Includes:
Singleton
Defined in:
lib/github_api/browser.rb

Overview

Handles low-level HTTP requests

Class Method Summary collapse

Class Method Details

.base_uriString

Returnes root uri for GitHub API

Returns:

  • (String)

    Base GitHub API url for v2



8
9
10
# File 'lib/github_api/browser.rb', line 8

def self.base_uri
  "http://github.com/api/v2/yaml"
end

.get(uri) ⇒ String

Runs HTTP GET request at given uri

Parameters:

  • uri (String)

    URI to be joined with base_uri and requested

Returns:

  • (String)

    request result



15
16
17
18
19
# File 'lib/github_api/browser.rb', line 15

def self.get(uri)
  uri = uri.gsub(" ","+")
  puts "Requesting #{URI.parse(self.base_uri + uri)}"
  Net::HTTP.get URI.parse(self.base_uri + uri)
end

.post(uri, options = {}) ⇒ String

Runs HTTP POST requests with options such as GitHub::User.auth_info

Parameters:

  • uri (String)

    URI to be joined with base_uri and requested

Returns:

  • (String)

    request result



24
25
26
27
28
# File 'lib/github_api/browser.rb', line 24

def self.post(uri, options = {})
  uri = uri.gsub(" ","+")
  puts "Requesting #{URI.parse(self.base_uri + uri)} with options: #{options}"
  Net::HTTP.post_form URI.parse(self.base_uri + uri), options
end