gitlab-org--gitlab-foss/lib/gitlab/string_regex_marker.rb

22 lines
448 B
Ruby
Raw Normal View History

# frozen_string_literal: true
2016-07-10 16:17:20 -04:00
module Gitlab
class StringRegexMarker < StringRangeMarker
def mark(regex, group: 0, &block)
ranges = []
offset = 0
2016-07-10 16:17:20 -04:00
while match = regex.match(raw_line[offset..])
begin_index = match.begin(group) + offset
end_index = match.end(group) + offset
2016-07-10 16:17:20 -04:00
ranges << (begin_index..(end_index - 1))
offset = end_index
end
super(ranges, &block)
2016-07-10 16:17:20 -04:00
end
end
end