Welcome to mirror list, hosted at ThFree Co, Russian Federation.

string_regex_marker.rb « gitlab « lib - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 8e0167a433e8391955efd77304c6e94f9731cefc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# frozen_string_literal: true

module Gitlab
  class StringRegexMarker < StringRangeMarker
    def mark(regex, group: 0, &block)
      ranges = []
      offset = 0

      while match = regex.match(raw_line[offset..])
        begin_index = match.begin(group) + offset
        end_index = match.end(group) + offset

        ranges << (begin_index..(end_index - 1))

        offset = end_index
      end

      super(ranges, &block)
    end
  end
end