diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2014-02-28 18:10:39 -0800 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2014-02-28 18:10:39 -0800 |
commit | 960d30ef5ac4ab93db199852fcd93f3cc3dfe1dd (patch) | |
tree | c994e1379c146c60716d59fedd8db8f7f7342723 /lib | |
parent | 5e6a486f3c0cde1529e47e4b74816284414762a4 (diff) | |
download | psych-960d30ef5ac4ab93db199852fcd93f3cc3dfe1dd.tar.gz |
* ext/psych/lib/psych/visitors/yaml_tree.rb: support dumping Encoding
objects.
* ext/psych/lib/psych/visitors/to_ruby.rb: support loading Encoding
objects.
* test/psych/test_encoding.rb: add test
* ext/psych/lib/psych.rb: add version
Diffstat (limited to 'lib')
-rw-r--r-- | lib/psych/visitors/to_ruby.rb | 2 | ||||
-rw-r--r-- | lib/psych/visitors/yaml_tree.rb | 5 |
2 files changed, 7 insertions, 0 deletions
diff --git a/lib/psych/visitors/to_ruby.rb b/lib/psych/visitors/to_ruby.rb index 42b328a..2f84b10 100644 --- a/lib/psych/visitors/to_ruby.rb +++ b/lib/psych/visitors/to_ruby.rb @@ -75,6 +75,8 @@ module Psych class_loader.date_time require 'date' @ss.parse_time(o.value).to_datetime + when '!ruby/encoding' + ::Encoding.find o.value when "!ruby/object:Complex" class_loader.complex Complex(o.value) diff --git a/lib/psych/visitors/yaml_tree.rb b/lib/psych/visitors/yaml_tree.rb index f89fcbb..ff0fcd2 100644 --- a/lib/psych/visitors/yaml_tree.rb +++ b/lib/psych/visitors/yaml_tree.rb @@ -157,6 +157,11 @@ module Psych @emitter.end_sequence end + def visit_Encoding o + tag = "!ruby/encoding" + @emitter.scalar o.name, nil, tag, false, false, Nodes::Scalar::ANY + end + def visit_Object o tag = Psych.dump_tags[o.class] unless tag |