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

18 lines
410 B
Ruby
Raw Normal View History

2017-09-10 17:25:29 +05:30
module Gitlab
class StringRegexMarker < StringRangeMarker
2018-12-05 23:21:45 +05:30
# rubocop: disable CodeReuse/ActiveRecord
2017-09-10 17:25:29 +05:30
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
2018-12-05 23:21:45 +05:30
# rubocop: enable CodeReuse/ActiveRecord
2017-09-10 17:25:29 +05:30
end
end