зеркало из https://github.com/github/ruby.git
* ext/psych/lib/psych/visitors/yaml_tree.rb: correctly quote non-ascii
letters. Thanks @jirutka for the patch. * test/psych/test_string.rb: test for change git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49190 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
Родитель
5dabead187
Коммит
344b8bbd69
|
@ -1,3 +1,10 @@
|
|||
Fri Jan 9 07:23:32 2015 Aaron Patterson <aaron@tenderlovemaking.com>
|
||||
|
||||
* ext/psych/lib/psych/visitors/yaml_tree.rb: correctly quote non-ascii
|
||||
letters. Thanks @jirutka for the patch.
|
||||
|
||||
* test/psych/test_string.rb: test for change
|
||||
|
||||
Fri Jan 9 07:13:55 2015 Aaron Patterson <aaron@tenderlovemaking.com>
|
||||
|
||||
* ext/psych/lib/psych/visitors/to_ruby.rb: call `allocate` on hash
|
||||
|
|
|
@ -317,7 +317,7 @@ module Psych
|
|||
tag = 'tag:yaml.org,2002:str'
|
||||
plain = false
|
||||
quote = false
|
||||
elsif o =~ /^\W[^"]*$/
|
||||
elsif o =~ /^[^[:word:]][^"]*$/
|
||||
style = Nodes::Scalar::DOUBLE_QUOTED
|
||||
else
|
||||
unless String === @ss.tokenize(o)
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# encoding: UTF-8
|
||||
require_relative 'helper'
|
||||
|
||||
module Psych
|
||||
|
@ -23,6 +24,11 @@ module Psych
|
|||
assert_equal 2, Psych.dump(%Q{<%= ENV["PATH"] %>}).count('"')
|
||||
end
|
||||
|
||||
def test_no_quotes_when_start_with_non_ascii_character
|
||||
yaml = Psych.dump 'Český non-ASCII'.encode(Encoding::UTF_8)
|
||||
assert_match(/---\s*[^"'!]+$/, yaml)
|
||||
end
|
||||
|
||||
def test_doublequotes_when_there_is_a_single
|
||||
yaml = Psych.dump "@123'abc"
|
||||
assert_match(/---\s*"/, yaml)
|
||||
|
|
Загрузка…
Ссылка в новой задаче