Class: Policial::Detective
- Inherits:
-
Object
- Object
- Policial::Detective
- 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
-
#github_client ⇒ Object
readonly
Returns the value of attribute github_client.
-
#pull_request ⇒ Object
readonly
Returns the value of attribute pull_request.
-
#violations ⇒ Object
Returns the value of attribute violations.
Instance Method Summary collapse
- #brief(event_or_attributes) ⇒ Object
-
#initialize(github_client = nil) ⇒ Detective
constructor
A new instance of Detective.
- #investigate(options = {}) ⇒ Object
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_client ⇒ Object (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_request ⇒ Object (readonly)
Returns the value of attribute pull_request.
8 9 10 |
# File 'lib/policial/detective.rb', line 8 def pull_request @pull_request end |
#violations ⇒ Object
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( = {}) return unless pull_request @violations ||= StyleChecker.new(pull_request, ).violations end |