Class: Policial::Detective

Inherits:
Object
  • Object
show all
Defined in:
lib/policial/detective.rb

Overview

Public: Starting with an Octokit client and a pull request, it checks all changes introduced looking for style guide violations.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(github_client = nil) ⇒ Detective

Returns a new instance of Detective.



10
11
12
# File 'lib/policial/detective.rb', line 10

def initialize(github_client = nil)
  @github_client = github_client || Octokit
end

Instance Attribute Details

#github_clientObject (readonly)

Returns the value of attribute github_client.



8
9
10
# File 'lib/policial/detective.rb', line 8

def github_client
  @github_client
end

#pull_requestObject (readonly)

Returns the value of attribute pull_request.



8
9
10
# File 'lib/policial/detective.rb', line 8

def pull_request
  @pull_request
end

#violationsObject

Returns the value of attribute violations.



7
8
9
# File 'lib/policial/detective.rb', line 7

def violations
  @violations
end

Instance Method Details

#brief(event_or_attributes) ⇒ Object



14
15
16
17
18
19
20
# File 'lib/policial/detective.rb', line 14

def brief(event_or_attributes)
  pull_request_attributes = extract_attributes(event_or_attributes)
  return unless pull_request_attributes
  @pull_request = PullRequest.new(
    pull_request_attributes.merge(github_client: @github_client)
  )
end

#investigate(options = {}) ⇒ Object



22
23
24
25
# File 'lib/policial/detective.rb', line 22

def investigate(options = {})
  return unless pull_request
  @violations ||= StyleChecker.new(pull_request, options).violations
end