Module: Marshalsea::Psych::Tags

Defined in:
lib/marshalsea/psych/inspector.rb

Constant Summary collapse

PATTERN =
%r{\A!ruby/(?<kind>[a-z_-]+)(?::(?<class_name>.+))?\z}
KIND_OBJECT =
"object"
KIND_HASH =
"hash"
KIND_ARRAY =
"array"
KIND_STRING =
"string"
KIND_STRUCT =
"struct"
KIND_EXCEPTION =
"exception"
KIND_MARSHALABLE =
"marshalable"
REVIVAL_METHODS =
{
  KIND_OBJECT => "init_with",
  KIND_HASH => "[]=",
  KIND_ARRAY => "init_with",
  KIND_STRING => "init_with",
  KIND_STRUCT => "init_with",
  KIND_EXCEPTION => "init_with",
  KIND_MARSHALABLE => "marshal_load"
}.freeze
GATED_KINDS =
[KIND_MARSHALABLE].freeze

Class Method Summary collapse

Class Method Details

.parse(tag) ⇒ Object



42
43
44
45
46
47
# File 'lib/marshalsea/psych/inspector.rb', line 42

def parse(tag)
  match = PATTERN.match(tag.to_s)
  return nil unless match

  [match[:kind], match[:class_name]]
end