Sha256: 41f82a17fe9480501d6175d643f7959e7790c7c3bfcf992536305a74d64a882a
Contents?: true
Size: 1.03 KB
Versions: 6
Compression:
Stored size: 1.03 KB
Contents
module SafeYAML class PsychResolver < Resolver NODE_TYPES = { Psych::Nodes::Document => :root, Psych::Nodes::Mapping => :map, Psych::Nodes::Sequence => :seq, Psych::Nodes::Scalar => :scalar, Psych::Nodes::Alias => :alias }.freeze def initialize super() @aliased_nodes = {} end def resolve_root(root) resolve_seq(root).first end def resolve_alias(node) resolve_node(@aliased_nodes[node.anchor]) end def native_resolve(node) @visitor ||= SafeYAML::SafeToRubyVisitor.new(self) @visitor.accept(node) end def get_node_type(node) NODE_TYPES[node.class] end def get_node_tag(node) node.tag end def get_node_value(node) @aliased_nodes[node.anchor] = node if node.respond_to?(:anchor) && node.anchor case get_node_type(node) when :root, :map, :seq node.children when :scalar node.value end end def value_is_quoted?(node) node.quoted end end end
Version data entries
6 entries across 6 versions & 1 rubygems