diff options
-rw-r--r-- | ext/psych/lib/psych/deprecated.rb | 10 | ||||
-rw-r--r-- | test/psych/test_deprecated.rb | 12 |
2 files changed, 22 insertions, 0 deletions
diff --git a/ext/psych/lib/psych/deprecated.rb b/ext/psych/lib/psych/deprecated.rb index 1d401d920f..dd4ca6b68f 100644 --- a/ext/psych/lib/psych/deprecated.rb +++ b/ext/psych/lib/psych/deprecated.rb @@ -56,6 +56,16 @@ module Psych return thing unless String === thing "tag:yaml.org,2002:#{thing}" end + + def self.read_type_class type, reference + warn "#{caller[0]}: read_type_class is deprecated" if $VERBOSE + _, _, type, name = type.split ':', 4 + + reference = name.split('::').inject(reference) do |k,n| + k.const_get(n.to_sym) + end if name + [type, reference] + end end class Object diff --git a/test/psych/test_deprecated.rb b/test/psych/test_deprecated.rb index 6db7238b0c..2312600ac8 100644 --- a/test/psych/test_deprecated.rb +++ b/test/psych/test_deprecated.rb @@ -187,5 +187,17 @@ module Psych assert_equal Psych, Psych.tagurize(Psych) assert_equal 'tag:yaml.org,2002:foo', Psych.tagurize('foo') end + + def test_read_type_class + things = Psych.read_type_class 'tag:yaml.org,2002:int:Psych::TestDeprecated::QuickEmitter', Object + assert_equal 'int', things.first + assert_equal Psych::TestDeprecated::QuickEmitter, things.last + end + + def test_read_type_class_no_class + things = Psych.read_type_class 'tag:yaml.org,2002:int', Object + assert_equal 'int', things.first + assert_equal Object, things.last + end end end |