Class: CleoQualityReview::DiffMap
- Inherits:
-
Object
- Object
- CleoQualityReview::DiffMap
- Defined in:
- lib/cleo_quality_review/diff_map.rb
Overview
Maps a unified git diff to right-side line numbers that GitHub can comment on
Defined Under Namespace
Classes: DiffParser
Constant Summary collapse
- HUNK_HEADER =
/^@@ -\d+(?:,\d+)? \+(?<line>\d+)(?:,\d+)? @@/.freeze
Instance Method Summary collapse
- #commentable?(filepath, line) ⇒ Boolean
-
#initialize(diff) ⇒ DiffMap
constructor
A new instance of DiffMap.
Constructor Details
#initialize(diff) ⇒ DiffMap
Returns a new instance of DiffMap.
73 74 75 76 77 |
# File 'lib/cleo_quality_review/diff_map.rb', line 73 def initialize(diff) @diff = diff.to_s @commentable_lines = Hash.new { |hash, key| hash[key] = Set.new } parse end |
Instance Method Details
#commentable?(filepath, line) ⇒ Boolean
83 84 85 |
# File 'lib/cleo_quality_review/diff_map.rb', line 83 def commentable?(filepath, line) commentable_lines[filepath.to_s].include?(line.to_i) end |