class Gem::YAMLSerializer::Parser

Constants

MAPPING_KEY_RE

A plain (unquoted) mapping key followed by “:”. “#” inside a key is literal unless preceded by a space (which would start a comment).

MAX_NESTING_DEPTH
QUOTED_KEY_RE

A quoted mapping key followed by “:”. A whole-line quoted scalar cannot match because its closing quote is at the end of the line.

STRING_UNESCAPES

Public Class Methods

# File lib/rubygems/yaml_serializer.rb, line 58
def initialize(source)
  @lines = source.split(/\r?\n/)
  @anchors = {}
  @depth = 0
  strip_document_prefix
end

Public Instance Methods

# File lib/rubygems/yaml_serializer.rb, line 65
def parse
  return nil if @lines.empty?

  root = nil
  while @lines.any?
    before = @lines.size
    node = parse_node(-1)
    @lines.shift if @lines.size == before && @lines.any?

    if root.is_a?(Mapping) && node.is_a?(Mapping)
      root.pairs.concat(node.pairs)
    elsif root.nil?
      root = node
    end
  end
  root
end