1
0
Fork 0
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: use double quotes when

strings start with special characters.
  [Fixes GH-157] https://github.com/tenderlove/psych/issues/157

* test/psych/test_string.rb: test for change.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42850 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
tenderlove 2013-09-05 17:39:53 +00:00
parent a9ab13669c
commit 8579a33966
3 changed files with 15 additions and 0 deletions

View file

@ -1,3 +1,11 @@
Fri Sep 6 02:37:22 2013 Aaron Patterson <aaron@tenderlovemaking.com>
* ext/psych/lib/psych/visitors/yaml_tree.rb: use double quotes when
strings start with special characters.
[Fixes GH-157] https://github.com/tenderlove/psych/issues/157
* test/psych/test_string.rb: test for change.
Fri Sep 6 00:05:14 2013 Nobuyoshi Nakada <nobu@ruby-lang.org>
* class.c (rewrite_cref_stack): remove recursion.

View file

@ -288,6 +288,8 @@ module Psych
quote = false
elsif o =~ /\n/
style = Nodes::Scalar::LITERAL
elsif o =~ /^\W/
style = Nodes::Scalar::DOUBLE_QUOTED
else
unless String === @ss.tokenize(o)
style = Nodes::Scalar::SINGLE_QUOTED

View file

@ -15,6 +15,11 @@ module Psych
end
end
def test_doublequotes_when_there_is_a_single
yaml = Psych.dump "@123'abc"
assert_match(/---\s*"/, yaml)
end
def test_dash_dot
assert_cycle '-.'
assert_cycle '+.'