Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

* 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
  • Loading branch information...
commit 960d30ef5ac4ab93db199852fcd93f3cc3dfe1dd 1 parent 5e6a486
@tenderlove authored
View
12 CHANGELOG.rdoc
@@ -1,3 +1,15 @@
+Sat Mar 1 11:08:00 2014 Aaron Patterson <aaron@tenderlovemaking.com>
+
+ * 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
+
Wed Feb 5 10:11:36 2014 Zachary Scott <e@zzak.io>
* ext/psych/yaml/config.h: bump libyaml to 0.1.5
View
2  lib/psych/visitors/to_ruby.rb
@@ -75,6 +75,8 @@ def deserialize o
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)
View
5 lib/psych/visitors/yaml_tree.rb
@@ -157,6 +157,11 @@ def visit_Psych_Omap o
@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
View
5 test/psych/test_encoding.rb
@@ -31,6 +31,11 @@ def setup
@emitter = Psych::Emitter.new @buffer
end
+ def test_dump_load_encoding_object
+ assert_cycle Encoding::US_ASCII
+ assert_cycle Encoding::UTF_8
+ end
+
def test_transcode_shiftjis
str = "こんにちは!"
loaded = Psych.load("--- こんにちは!".encode('SHIFT_JIS'))
Please sign in to comment.
Something went wrong with that request. Please try again.