summaryrefslogtreecommitdiff
path: root/ext
diff options
context:
space:
mode:
authornagachika <nagachika@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-05-04 15:40:57 +0000
committernagachika <nagachika@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-05-04 15:40:57 +0000
commit7c89c50847c6579a98e825af58bacb007ef15b55 (patch)
tree253701eb7503e13527667418d4bfd74aa5b6c598 /ext
parent71fdd26db0365546baeb8e046c4192358d8d6b2a (diff)
merge revision(s) r45221: [Backport #9798]
* 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 git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@45811 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext')
-rw-r--r--ext/psych/lib/psych.rb2
-rw-r--r--ext/psych/lib/psych/visitors/to_ruby.rb2
-rw-r--r--ext/psych/lib/psych/visitors/yaml_tree.rb5
3 files changed, 8 insertions, 1 deletions
diff --git a/ext/psych/lib/psych.rb b/ext/psych/lib/psych.rb
index 4b422f5644..55d68dcd51 100644
--- a/ext/psych/lib/psych.rb
+++ b/ext/psych/lib/psych.rb
@@ -217,7 +217,7 @@ require 'psych/class_loader'
module Psych
# The version is Psych you're using
- VERSION = '2.0.3'
+ VERSION = '2.0.4'
# The version of libyaml Psych is using
LIBYAML_VERSION = Psych.libyaml_version.join '.'
diff --git a/ext/psych/lib/psych/visitors/to_ruby.rb b/ext/psych/lib/psych/visitors/to_ruby.rb
index 1bfffb952f..5c3baa5b68 100644
--- a/ext/psych/lib/psych/visitors/to_ruby.rb
+++ b/ext/psych/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/ext/psych/lib/psych/visitors/yaml_tree.rb b/ext/psych/lib/psych/visitors/yaml_tree.rb
index f89fcbb8f1..ff0fcd204c 100644
--- a/ext/psych/lib/psych/visitors/yaml_tree.rb
+++ b/ext/psych/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