debian-mirror-gitlab/lib/gitlab/string_regex_marker.rb

16 lines
319 B
Ruby
Raw Normal View History

2017-09-10 17:25:29 +05:30
module Gitlab
class StringRegexMarker < StringRangeMarker
def mark(regex, group: 0, &block)
2018-03-27 19:54:05 +05:30
ranges = []
2017-09-10 17:25:29 +05:30
2018-03-27 19:54:05 +05:30
raw_line.scan(regex) do
begin_index, end_index = Regexp.last_match.offset(group)
2017-09-10 17:25:29 +05:30
2018-03-27 19:54:05 +05:30
ranges << (begin_index..(end_index - 1))
end
super(ranges, &block)
2017-09-10 17:25:29 +05:30
end
end
end