Module: Pod::GitHub
- Defined in:
- lib/cocoapods-core/github.rb
Overview
Allows to access information about the GitHub repos.
This class is stored in Core because it might be used by web services.
Private helpers collapse
-
.normalized_repo_id(url_or_id) ⇒ String
Returns the repo ID as it is or converting a GitHub URL.
-
.peform_request(url) ⇒ Array, Hash
Performs a get request with the given URL.
-
.repo_id_from_url(url) ⇒ String, Nil
Returns the repo ID given it’s URL.
Class Method Summary collapse
-
.branches(url) ⇒ Array
Returns the branches of a repo.
-
.repo(url) ⇒ Hash
Returns the information of a repo.
-
.tags(url) ⇒ Array
Returns the tags of a repo.
-
.user(login) ⇒ Hash
Returns the information of a user.
Class Method Details
.branches(url) ⇒ Array
Returns the branches of a repo.
51 52 53 54 55 |
# File 'lib/cocoapods-core/github.rb', line 51 def self.branches(url) if repo_id = normalized_repo_id(url) peform_request("https://api.github.com/repos/#{repo_id}/branches") end end |
.normalized_repo_id(url_or_id) ⇒ String
Returns the repo ID as it is or converting a GitHub URL.
70 71 72 |
# File 'lib/cocoapods-core/github.rb', line 70 def self.normalized_repo_id(url_or_id) repo_id_from_url(url_or_id) || url_or_id end |
.peform_request(url) ⇒ Array, Hash
Performs a get request with the given URL.
93 94 95 96 97 98 |
# File 'lib/cocoapods-core/github.rb', line 93 def self.peform_request(url) require 'rest' require 'json' response = REST.get(url) JSON.parse(response.body) end |
.repo(url) ⇒ Hash
Returns the information of a repo.
27 28 29 30 31 |
# File 'lib/cocoapods-core/github.rb', line 27 def self.repo(url) if repo_id = normalized_repo_id(url) peform_request("https://api.github.com/repos/#{repo_id}") end end |
.repo_id_from_url(url) ⇒ String, Nil
Returns the repo ID given it’s URL.
82 83 84 |
# File 'lib/cocoapods-core/github.rb', line 82 def self.repo_id_from_url(url) url[%r[github.com/([^/\.]*/[^/\.]*)\.*], 1] end |
.tags(url) ⇒ Array
Returns the tags of a repo.
39 40 41 42 43 |
# File 'lib/cocoapods-core/github.rb', line 39 def self.(url) if repo_id = normalized_repo_id(url) peform_request("https://api.github.com/repos/#{repo_id}/tags") end end |
.user(login) ⇒ Hash
Returns the information of a user.
16 17 18 |
# File 'lib/cocoapods-core/github.rb', line 16 def self.user(login) peform_request("https://api.github.com/users/#{login}") end |