Class: Linterbot::ResultHandler

Inherits:
Object
  • Object
show all
Defined in:
lib/linterbot/result_handler.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(pull_request, commenter, approver) ⇒ ResultHandler

Returns a new instance of ResultHandler.



10
11
12
13
14
# File 'lib/linterbot/result_handler.rb', line 10

def initialize(pull_request, commenter, approver)
  @pull_request = pull_request
  @commenter = commenter
  @approver = approver
end

Instance Attribute Details

#approverObject

Returns the value of attribute approver.



8
9
10
# File 'lib/linterbot/result_handler.rb', line 8

def approver
  @approver
end

#commenterObject

Returns the value of attribute commenter.



7
8
9
# File 'lib/linterbot/result_handler.rb', line 7

def commenter
  @commenter
end

#github_clientObject

Returns the value of attribute github_client.



6
7
8
# File 'lib/linterbot/result_handler.rb', line 6

def github_client
  @github_client
end

#pull_requestObject

Returns the value of attribute pull_request.



5
6
7
# File 'lib/linterbot/result_handler.rb', line 5

def pull_request
  @pull_request
end

Instance Method Details

#handle(result) ⇒ Object



16
17
18
19
20
21
22
23
24
# File 'lib/linterbot/result_handler.rb', line 16

def handle(result)
  result.comments.each { |comment| commenter.publish_comment(comment) }
  commenter.publish_summary(result.summary)
  if result.serious_violations?
    reject_pull_request(result.serious_violations_count)
  else
    approve_pull_request
  end
end