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
|
2018-08-27 15:31:01 +00:00
|
|
|
# rubocop: disable CodeReuse/ActiveRecord
|
2016-07-10 20:17:20 +00:00
|
|
|
def mark(regex, group: 0, &block)
|
2018-02-16 13:33:50 +00:00
|
|
|
ranges = []
|
2016-07-10 20:17:20 +00:00
|
|
|
|
2018-02-16 13:33:50 +00:00
|
|
|
raw_line.scan(regex) do
|
|
|
|
begin_index, end_index = Regexp.last_match.offset(group)
|
2016-07-10 20:17:20 +00:00
|
|
|
|
2018-02-16 13:33:50 +00:00
|
|
|
ranges << (begin_index..(end_index - 1))
|
|
|
|
end
|
|
|
|
|
|
|
|
super(ranges, &block)
|
2016-07-10 20:17:20 +00:00
|
|
|
end
|
2018-08-27 15:31:01 +00:00
|
|
|
# rubocop: enable CodeReuse/ActiveRecord
|
2016-07-10 20:17:20 +00:00
|
|
|
end
|
|
|
|
end
|