Class: GitHub::Browser
- Inherits:
-
Object
- Object
- GitHub::Browser
- Includes:
- Singleton
- Defined in:
- lib/github-api-client/browser.rb
Overview
Handles low-level HTTP requests
Class Method Summary collapse
-
.base_uri(version = 'v2') ⇒ String
Returnes root uri for GitHub API.
-
.get(uri, version = 'v2') ⇒ String
Runs HTTP GET request at given uri.
-
.patch(uri, options = {}, version = 'v2') ⇒ String
Runs HTTP PATCH request at a given uri.
-
.post(uri, options = {}, version = 'v2') ⇒ String
Runs HTTP POST requests with options such as GitHub::User.auth_info.
Class Method Details
.base_uri(version = 'v2') ⇒ String
Returnes root uri for GitHub API
12 13 14 15 |
# File 'lib/github-api-client/browser.rb', line 12 def self.base_uri(version = 'v2') gh_uri = GitHub::Config::Options[:server]||'github.com' "http://#{gh_uri}/api/#{version}/yaml" end |
.get(uri, version = 'v2') ⇒ String
Runs HTTP GET request at given uri
20 21 22 23 24 |
# File 'lib/github-api-client/browser.rb', line 20 def self.get(uri, version = 'v2') uri = URI.parse(self.base_uri(version) + uri.gsub(" ","+")) puts "Requesting #{uri}" if GitHub::Config::Options[:verbose] Net::HTTP.get uri end |
.patch(uri, options = {}, version = 'v2') ⇒ String
Runs HTTP PATCH request at a given uri
38 39 40 41 42 |
# File 'lib/github-api-client/browser.rb', line 38 def self.patch(uri, = {}, version = 'v2') uri = uri.gsub(" ","+") puts "Requesting #{URI.parse(self.base_uri(version) + uri)} with options: #{}" if GitHub::Config::Options[:verbose] Net::HTTP.patch URI.parse(self.base_uri + uri), end |
.post(uri, options = {}, version = 'v2') ⇒ String
Runs HTTP POST requests with options such as GitHub::User.auth_info
29 30 31 32 33 |
# File 'lib/github-api-client/browser.rb', line 29 def self.post(uri, = {}, version = 'v2') uri = URI.parse(self.base_uri(version) + uri.gsub(" ","+")) puts "Requesting #{uri} with options: #{}" if GitHub::Config::Options[:verbose] Net::HTTP.post_form uri, end |