Class: Ghrt::Github
- Inherits:
-
Object
- Object
- Ghrt::Github
- Defined in:
- lib/ghrt/github.rb
Instance Method Summary collapse
-
#initialize(repo, verbose) ⇒ Github
constructor
A new instance of Github.
- #review_comments(pull_request, since) ⇒ Object
Constructor Details
#initialize(repo, verbose) ⇒ Github
10 11 12 13 14 15 16 17 |
# File 'lib/ghrt/github.rb', line 10 def initialize(repo, verbose) @repo = repo @username = ENV['GITHUB_USERNAME'] @token = ENV['GITHUB_TOKEN'] raise 'GITHUB_USERNAME and GITHUB_TOKEN environment variables must be set' unless @username && @token @verbose = verbose end |
Instance Method Details
#review_comments(pull_request, since) ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/ghrt/github.rb', line 19 def review_comments(pull_request, since) response = [] page = 1 loop do paged_response = query_github("/pulls/#{pull_request}/comments?since=#{since}&per_page=100&page=#{page}") break if paged_response.empty? response.concat(paged_response) page += 1 end response.select { |comment| comment['user']['login'] == @username } end |