Class: CodeClimate
- Inherits:
-
Object
- Object
- CodeClimate
- Defined in:
- lib/code_climate.rb
Constant Summary collapse
- BASE_URL =
'https://codeclimate.com'
Class Method Summary collapse
-
.get_branch(repo_id:, branch_name:) ⇒ Object
GET /api/repos/:repo_id/branches/:branch_name.
-
.get_repo(repo_id:) ⇒ Object
GET /api/repos/:repo_id.
-
.get_repos ⇒ Object
GET /api/repos.
-
.refresh_branch(repo_id:, branch_name:) ⇒ Object
POST /api/repos/:repo_id/branches/:branch_name/refresh.
-
.refresh_repo(repo_id:) ⇒ Object
POST /api/repos/:repo_id/refresh.
Class Method Details
.get_branch(repo_id:, branch_name:) ⇒ Object
GET /api/repos/:repo_id/branches/:branch_name
30 31 32 33 34 35 |
# File 'lib/code_climate.rb', line 30 def self.get_branch(repo_id:, branch_name:) connection = connection("/api/repos/#{repo_id}/branches/#{branch_name}") response = connection.get(query: { api_token: api_token }) Branch.new(JSON.parse(response.body)) end |
.get_repo(repo_id:) ⇒ Object
GET /api/repos/:repo_id
14 15 16 17 18 19 |
# File 'lib/code_climate.rb', line 14 def self.get_repo(repo_id:) connection = connection("/api/repos/#{repo_id}") response = connection.get(query: { api_token: api_token }) Repo.new(JSON.parse(response.body)) end |
.get_repos ⇒ Object
GET /api/repos
5 6 7 8 9 10 11 |
# File 'lib/code_climate.rb', line 5 def self.get_repos connection = connection('/api/repos') response = connection.get(query: { api_token: api_token }) repos = JSON.parse(response.body) repos.map { |repo| Repo.new(repo) } end |
.refresh_branch(repo_id:, branch_name:) ⇒ Object
POST /api/repos/:repo_id/branches/:branch_name/refresh
38 39 40 41 42 43 |
# File 'lib/code_climate.rb', line 38 def self.refresh_branch(repo_id:, branch_name:) connection = connection("/api/repos/#{repo_id}/branches/#{branch_name}/refresh") response = connection.post(query: { api_token: api_token }) response.status == 200 ? true : false end |
.refresh_repo(repo_id:) ⇒ Object
POST /api/repos/:repo_id/refresh
22 23 24 25 26 27 |
# File 'lib/code_climate.rb', line 22 def self.refresh_repo(repo_id:) connection = connection("/api/repos/#{repo_id}/refresh") response = connection.post(query: { api_token: api_token }) response.status == 200 ? true : false end |