class Linterbot::Patch
Constants
- MODIFIED_FILE_DIFF_REGEXP
Attributes
patch_content[RW]
Public Class Methods
new(patch_content)
click to toggle source
# File lib/linterbot/patch.rb, line 9 def initialize(patch_content) @patch_content = patch_content end
Public Instance Methods
additions_ranges()
click to toggle source
# File lib/linterbot/patch.rb, line 17 def additions_ranges chunks_headers.map do |diff_header, line_number| match = diff_header.match(MODIFIED_FILE_DIFF_REGEXP) line_start = match[1].to_i line_end = line_start + match[2].to_i [line_start...line_end, line_number] end end
additions_ranges_for_hint(hint)
click to toggle source
# File lib/linterbot/patch.rb, line 26 def additions_ranges_for_hint(hint) additions_ranges.select { |diff_range, line_number| diff_range.include?(hint.line) } end
chunks_headers()
click to toggle source
# File lib/linterbot/patch.rb, line 13 def chunks_headers @chunks_headers ||= parse_chunks_headers end
included_in_patch?(hint)
click to toggle source
# File lib/linterbot/patch.rb, line 30 def included_in_patch?(hint) additions_ranges_for_hint(hint).count > 0 end
Private Instance Methods
parse_chunks_headers()
click to toggle source
# File lib/linterbot/patch.rb, line 36 def parse_chunks_headers patch_content .split("\n") .each_with_index .select { |line, line_number| line.start_with?("@@") } end