Class: Typocop::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/typocop/client.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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.)
  end
end

Instance Attribute Details

#pull_commentsObject (readonly)

Returns the value of attribute pull_comments.



3
4
5
# File 'lib/typocop/client.rb', line 3

def pull_comments
  @pull_comments
end

#repoObject (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