Class: Typocop::Client
- Inherits:
-
Object
- Object
- Typocop::Client
- Defined in:
- lib/typocop/client.rb
Instance Attribute Summary collapse
-
#pull_comments ⇒ Object
readonly
Returns the value of attribute pull_comments.
-
#repo ⇒ Object
readonly
Returns the value of attribute repo.
Instance Method Summary collapse
- #execute(cops) ⇒ Object
-
#initialize(repo) ⇒ Client
constructor
A new instance of Client.
Constructor Details
#initialize(repo) ⇒ Client
Returns a new instance of Client.
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/typocop/client.rb', line 5 def initialize(repo) @client = Octokit::Client.new( api_endpoint: 'https://api.github.com/', web_endpoint: 'https://github.com/', access_token: GITHUB_TOKEN, auto_paginate: true ) @repo = repo @repo_name = @repo.name pull_comments = @client.pull_request_comments(@repo_name, PULL_ID) @pull_comments = pull_comments.map do |comment| Comment.new(comment.id, comment.path, comment.line, comment.body, comment.user.login) end end |
Instance Attribute Details
#pull_comments ⇒ Object (readonly)
Returns the value of attribute pull_comments.
3 4 5 |
# File 'lib/typocop/client.rb', line 3 def pull_comments @pull_comments end |
#repo ⇒ Object (readonly)
Returns the value of attribute repo.
3 4 5 |
# File 'lib/typocop/client.rb', line 3 def repo @repo end |
Instance Method Details
#execute(cops) ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/typocop/client.rb', line 21 def execute(cops) current_cops = current_cops(cops) if current_cops.empty? delete_all_comments accept_pull_request else dismiss_accept_pull_request delete_comments(current_cops) create_comments(current_cops) end end |