ruby-changes:15609
From: tenderlove <ko1@a...>
Date: Wed, 28 Apr 2010 05:19:26 +0900 (JST)
Subject: [ruby-changes:15609] Ruby:r27518 (trunk): * ext/psych/lib/psych/deprecated.rb: adding deprecated "read_type_class"
tenderlove 2010-04-28 05:19:16 +0900 (Wed, 28 Apr 2010) New Revision: 27518 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=27518 Log: * ext/psych/lib/psych/deprecated.rb: adding deprecated "read_type_class" method * test/psych/test_deprecated.rb: ditto Modified files: trunk/ext/psych/lib/psych/deprecated.rb trunk/test/psych/test_deprecated.rb Index: ext/psych/lib/psych/deprecated.rb =================================================================== --- ext/psych/lib/psych/deprecated.rb (revision 27517) +++ ext/psych/lib/psych/deprecated.rb (revision 27518) @@ -56,6 +56,16 @@ 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 Index: test/psych/test_deprecated.rb =================================================================== --- test/psych/test_deprecated.rb (revision 27517) +++ test/psych/test_deprecated.rb (revision 27518) @@ -187,5 +187,17 @@ 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 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/