Class: RepoAnalyzer::GithubClient
- Inherits:
-
Object
- Object
- RepoAnalyzer::GithubClient
- Defined in:
- app/clients/repo_analyzer/github_client.rb
Instance Method Summary collapse
- #commits(repo_name, from_date: nil, to_date: nil) ⇒ Object
- #contributors(repo_name) ⇒ Object
- #file_content(repo_name, file_path) ⇒ Object
-
#initialize(personal_token) ⇒ GithubClient
constructor
A new instance of GithubClient.
Constructor Details
#initialize(personal_token) ⇒ GithubClient
Returns a new instance of GithubClient.
3 4 5 |
# File 'app/clients/repo_analyzer/github_client.rb', line 3 def initialize(personal_token) @personal_token = personal_token end |
Instance Method Details
#commits(repo_name, from_date: nil, to_date: nil) ⇒ Object
11 12 13 14 15 |
# File 'app/clients/repo_analyzer/github_client.rb', line 11 def commits(repo_name, from_date: nil, to_date: nil) from_date ||= Date.current - 2.years to_date ||= Date.tomorrow client.commits_between(repo_name, from_date.to_s, to_date.to_s) end |
#contributors(repo_name) ⇒ Object
7 8 9 |
# File 'app/clients/repo_analyzer/github_client.rb', line 7 def contributors(repo_name) client.contributors(repo_name, true) end |
#file_content(repo_name, file_path) ⇒ Object
17 18 19 20 21 |
# File 'app/clients/repo_analyzer/github_client.rb', line 17 def file_content(repo_name, file_path) Base64.decode64(client.content(repo_name, path: file_path)[:content]) rescue Octokit::NotFound "" end |