mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* ext/psych/lib/psych/visitors/to_ruby.rb: Ruby classes can be loaded
from YAML files. * ext/psych/lib/psych/visitors/yaml_tree.rb: Ruby classes can be dumped to YAML files. * test/psych/test_class.rb: corresponding test. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31958 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
c84bb5df6d
commit
c641e4b23e
4 changed files with 19 additions and 6 deletions
|
@ -1,3 +1,11 @@
|
|||
Thu Jun 9 09:05:04 2011 Aaron Patterson <aaron@tenderlovemaking.com>
|
||||
|
||||
* ext/psych/lib/psych/visitors/to_ruby.rb: Ruby classes can be loaded
|
||||
from YAML files.
|
||||
* ext/psych/lib/psych/visitors/yaml_tree.rb: Ruby classes can be
|
||||
dumped to YAML files.
|
||||
* test/psych/test_class.rb: corresponding test.
|
||||
|
||||
Wed Jun 8 21:38:57 2011 CHIKANAGA Tomoyuki <nagachika00@gmail.com>
|
||||
|
||||
* cont.c (root_fiber_alloc): set root fiber's status RUNNING.
|
||||
|
|
|
@ -57,6 +57,8 @@ module Psych
|
|||
Complex(o.value)
|
||||
when "!ruby/object:Rational"
|
||||
Rational(o.value)
|
||||
when "!ruby/class"
|
||||
resolve_class o.value
|
||||
when "tag:yaml.org,2002:float", "!float"
|
||||
Float(@ss.tokenize(o.value))
|
||||
when "!ruby/regexp"
|
||||
|
|
|
@ -247,7 +247,8 @@ module Psych
|
|||
end
|
||||
|
||||
def visit_Class o
|
||||
raise TypeError, "can't dump anonymous class #{o.class}"
|
||||
raise TypeError, "can't dump anonymous class: #{o}" unless o.name
|
||||
@emitter.scalar o.name, nil, '!ruby/class', false, false, Nodes::Scalar::SINGLE_QUOTED
|
||||
end
|
||||
|
||||
def visit_Range o
|
||||
|
|
|
@ -2,16 +2,18 @@ require 'psych/helper'
|
|||
|
||||
module Psych
|
||||
class TestClass < TestCase
|
||||
def test_cycle
|
||||
def test_cycle_anonymous_class
|
||||
assert_raises(::TypeError) do
|
||||
assert_cycle(TestClass)
|
||||
assert_cycle(Class.new)
|
||||
end
|
||||
end
|
||||
|
||||
def test_cycle
|
||||
assert_cycle(TestClass)
|
||||
end
|
||||
|
||||
def test_dump
|
||||
assert_raises(::TypeError) do
|
||||
Psych.dump TestClass
|
||||
end
|
||||
Psych.dump TestClass
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue