summaryrefslogtreecommitdiff
path: root/lib/psych/visitors
diff options
context:
space:
mode:
authorAaron Patterson <aaron.patterson@gmail.com>2014-02-28 18:10:39 -0800
committerAaron Patterson <aaron.patterson@gmail.com>2014-02-28 18:10:39 -0800
commit960d30ef5ac4ab93db199852fcd93f3cc3dfe1dd (patch)
treec994e1379c146c60716d59fedd8db8f7f7342723 /lib/psych/visitors
parent5e6a486f3c0cde1529e47e4b74816284414762a4 (diff)
downloadpsych-960d30ef5ac4ab93db199852fcd93f3cc3dfe1dd.zip
* 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/psych/visitors')
-rw-r--r--lib/psych/visitors/to_ruby.rb2
-rw-r--r--lib/psych/visitors/yaml_tree.rb5
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