class Gem::YAMLSerializer::Parser
Constants
- BLANK_OR_COMMENT_RE
- BLANK_RE
- DOCUMENT_END_RE
- FLOW_SEQUENCE_ENTRY_RE
-
An entry of a flow sequence. A quoted entry may contain commas.
- LSTRIP_BYTES
- 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). Like
Psych, spaces and tabs may separate the “:” from the value. - MAX_NESTING_DEPTH
- NULL_SCALARS
- OPEN_QUOTED_RE
-
A quoted scalar whose closing quote is on a later line.
- 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.
- RUBY_OBJECT_TAG_RE
- SEQUENCE_ENTRY_RE
- STRING_UNESCAPES
- UTF8_BOM_BYTES
Public Class Methods
# File lib/rubygems/yaml_serializer.rb, line 65 def initialize(source) raise TypeError, "no implicit conversion of nil into String" if source.nil? source = strip_bom(source) # Keep trailing empty lines, which a block scalar with keep chomping # ("|+") preserves, but not the empty string after the final line # break. @lines = source.split(/\r?\n/, -1) @lines.pop if @lines.last == "" @lines.each(&:freeze) @anchors = {} @depth = 0 strip_document_end strip_document_prefix end
Public Instance Methods
# File lib/rubygems/yaml_serializer.rb, line 81 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