Class: Linterbot::CommentGenerator
- Inherits:
-
Object
- Object
- Linterbot::CommentGenerator
- Defined in:
- lib/linterbot/comment_generator.rb
Instance Attribute Summary collapse
-
#commit ⇒ Object
Returns the value of attribute commit.
-
#commits_count_for_file ⇒ Object
Returns the value of attribute commits_count_for_file.
-
#filename ⇒ Object
Returns the value of attribute filename.
-
#pull_request_file_patch ⇒ Object
Returns the value of attribute pull_request_file_patch.
Instance Method Summary collapse
- #file ⇒ Object
- #generate_comment_for_hint(hint) ⇒ Object
- #generate_comments(hints) ⇒ Object
-
#initialize(filename, commit, pull_request_file_patch, commits_count_for_file) ⇒ CommentGenerator
constructor
A new instance of CommentGenerator.
Constructor Details
#initialize(filename, commit, pull_request_file_patch, commits_count_for_file) ⇒ CommentGenerator
Returns a new instance of CommentGenerator.
10 11 12 13 14 15 |
# File 'lib/linterbot/comment_generator.rb', line 10 def initialize(filename, commit, pull_request_file_patch, commits_count_for_file) @filename = filename @commit = commit @pull_request_file_patch = Patch.new(pull_request_file_patch) @commits_count_for_file = commits_count_for_file end |
Instance Attribute Details
#commit ⇒ Object
Returns the value of attribute commit.
6 7 8 |
# File 'lib/linterbot/comment_generator.rb', line 6 def commit @commit end |
#commits_count_for_file ⇒ Object
Returns the value of attribute commits_count_for_file.
8 9 10 |
# File 'lib/linterbot/comment_generator.rb', line 8 def commits_count_for_file @commits_count_for_file end |
#filename ⇒ Object
Returns the value of attribute filename.
5 6 7 |
# File 'lib/linterbot/comment_generator.rb', line 5 def filename @filename end |
#pull_request_file_patch ⇒ Object
Returns the value of attribute pull_request_file_patch.
7 8 9 |
# File 'lib/linterbot/comment_generator.rb', line 7 def pull_request_file_patch @pull_request_file_patch end |
Instance Method Details
#file ⇒ Object
29 30 31 |
# File 'lib/linterbot/comment_generator.rb', line 29 def file @file ||= find_file end |
#generate_comment_for_hint(hint) ⇒ Object
22 23 24 25 26 27 |
# File 'lib/linterbot/comment_generator.rb', line 22 def generate_comment_for_hint(hint) patch_line_number = comment_position_for_hint(hint) if patch_line_number Comment.new(sha: commit.sha, patch_line_number: patch_line_number, hint: hint) end end |
#generate_comments(hints) ⇒ Object
17 18 19 20 |
# File 'lib/linterbot/comment_generator.rb', line 17 def generate_comments(hints) hints.map { |hint| generate_comment_for_hint(hint) } .select { |comment| comment != nil } end |