mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* 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/trunk@45221 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
1964c2b14a
commit
db17d694ea
5 changed files with 25 additions and 1 deletions
12
ChangeLog
12
ChangeLog
|
@ -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
|
||||||
|
|
||||||
Sat Mar 1 10:52:34 2014 Zachary Scott <e@zzak.io>
|
Sat Mar 1 10:52:34 2014 Zachary Scott <e@zzak.io>
|
||||||
|
|
||||||
* README.EXT.ja: [DOC] Fix typo "macro macro" @utenmiki [Fixes GH-551]
|
* README.EXT.ja: [DOC] Fix typo "macro macro" @utenmiki [Fixes GH-551]
|
||||||
|
|
|
@ -217,7 +217,7 @@ require 'psych/class_loader'
|
||||||
|
|
||||||
module Psych
|
module Psych
|
||||||
# The version is Psych you're using
|
# The version is Psych you're using
|
||||||
VERSION = '2.0.3'
|
VERSION = '2.0.4'
|
||||||
|
|
||||||
# The version of libyaml Psych is using
|
# The version of libyaml Psych is using
|
||||||
LIBYAML_VERSION = Psych.libyaml_version.join '.'
|
LIBYAML_VERSION = Psych.libyaml_version.join '.'
|
||||||
|
|
|
@ -75,6 +75,8 @@ module Psych
|
||||||
class_loader.date_time
|
class_loader.date_time
|
||||||
require 'date'
|
require 'date'
|
||||||
@ss.parse_time(o.value).to_datetime
|
@ss.parse_time(o.value).to_datetime
|
||||||
|
when '!ruby/encoding'
|
||||||
|
::Encoding.find o.value
|
||||||
when "!ruby/object:Complex"
|
when "!ruby/object:Complex"
|
||||||
class_loader.complex
|
class_loader.complex
|
||||||
Complex(o.value)
|
Complex(o.value)
|
||||||
|
|
|
@ -157,6 +157,11 @@ module Psych
|
||||||
@emitter.end_sequence
|
@emitter.end_sequence
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def visit_Encoding o
|
||||||
|
tag = "!ruby/encoding"
|
||||||
|
@emitter.scalar o.name, nil, tag, false, false, Nodes::Scalar::ANY
|
||||||
|
end
|
||||||
|
|
||||||
def visit_Object o
|
def visit_Object o
|
||||||
tag = Psych.dump_tags[o.class]
|
tag = Psych.dump_tags[o.class]
|
||||||
unless tag
|
unless tag
|
||||||
|
|
|
@ -31,6 +31,11 @@ module Psych
|
||||||
@emitter = Psych::Emitter.new @buffer
|
@emitter = Psych::Emitter.new @buffer
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_dump_load_encoding_object
|
||||||
|
assert_cycle Encoding::US_ASCII
|
||||||
|
assert_cycle Encoding::UTF_8
|
||||||
|
end
|
||||||
|
|
||||||
def test_transcode_shiftjis
|
def test_transcode_shiftjis
|
||||||
str = "こんにちは!"
|
str = "こんにちは!"
|
||||||
loaded = Psych.load("--- こんにちは!".encode('SHIFT_JIS'))
|
loaded = Psych.load("--- こんにちは!".encode('SHIFT_JIS'))
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue