self.parse

in lib/release_tools/helm/version_mapping.rb [18:63]


      def self.parse(markdown)
        lines = markdown.split("\n")
        start = lines.index(HEADER)

        if !start || lines[start + 1] != DIVIDER
          raise(ParseError, <<~ERROR.strip)
            The Markdown table is not formatted correctly.

            Markdown tables must start with the following header:

            
            
          ERROR
        end

        index = start + 2
        rows = []

        while index < lines.length
          line = lines[index].strip

          break if line.empty?

          _, raw_helm_version, raw_gitlab_version = line.split(/\s*\|\s*/)

          
          
          
          
          if raw_helm_version.to_s.empty? || raw_gitlab_version.to_s.empty?
            raise(
              ParseError,
              "The row #{line} must contain both a Helm and GitLab version"
            )
          end

          helm_version = Version.new(raw_helm_version)
          gitlab_version = Version.new(raw_gitlab_version)

          rows << Row.new(helm_version, gitlab_version)
          index += 1
        end

        new(lines: lines, rows: rows, start: start, stop: index - 1)
      end