2018-10-22 07:00:50 +00:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2016-07-10 20:17:20 +00:00
|
|
|
module Gitlab
|
|
|
|
class StringRegexMarker < StringRangeMarker
|
|
|
|
def mark(regex, group: 0, &block)
|
2018-02-16 13:33:50 +00:00
|
|
|
ranges = []
|
2021-09-30 18:11:31 +00:00
|
|
|
offset = 0
|
2016-07-10 20:17:20 +00:00
|
|
|
|
2021-09-30 18:11:31 +00:00
|
|
|
while match = regex.match(raw_line[offset..])
|
|
|
|
begin_index = match.begin(group) + offset
|
|
|
|
end_index = match.end(group) + offset
|
2016-07-10 20:17:20 +00:00
|
|
|
|
2018-02-16 13:33:50 +00:00
|
|
|
ranges << (begin_index..(end_index - 1))
|
2021-09-30 18:11:31 +00:00
|
|
|
|
|
|
|
offset = end_index
|
2018-02-16 13:33:50 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
super(ranges, &block)
|
2016-07-10 20:17:20 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|