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.
-
#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) ⇒ CommentGenerator
constructor
A new instance of CommentGenerator.
Constructor Details
#initialize(filename, commit, pull_request_file_patch) ⇒ CommentGenerator
Returns a new instance of CommentGenerator.
9 10 11 12 13 |
# File 'lib/linterbot/comment_generator.rb', line 9 def initialize(filename, commit, pull_request_file_patch) @filename = filename @commit = commit @pull_request_file_patch = Patch.new(pull_request_file_patch) 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 |
#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
28 29 30 |
# File 'lib/linterbot/comment_generator.rb', line 28 def file @file ||= find_file end |
#generate_comment_for_hint(hint) ⇒ Object
20 21 22 23 24 25 26 |
# File 'lib/linterbot/comment_generator.rb', line 20 def generate_comment_for_hint(hint) if new_file? generate_comment_for_new_file_and_hint(hint) elsif modified_file? && included_in_file_patch?(hint) generate_comment_for_modified_file_and_hint(hint) end end |
#generate_comments(hints) ⇒ Object
15 16 17 18 |
# File 'lib/linterbot/comment_generator.rb', line 15 def generate_comments(hints) hints.map { |hint| generate_comment_for_hint(hint) } .select { |comment| comment != nil } end |