* 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:
parent
a9ab13669c
commit
8579a33966
@ -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>
|
Fri Sep 6 00:05:14 2013 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||||
|
|
||||||
* class.c (rewrite_cref_stack): remove recursion.
|
* class.c (rewrite_cref_stack): remove recursion.
|
||||||
|
@ -288,6 +288,8 @@ module Psych
|
|||||||
quote = false
|
quote = false
|
||||||
elsif o =~ /\n/
|
elsif o =~ /\n/
|
||||||
style = Nodes::Scalar::LITERAL
|
style = Nodes::Scalar::LITERAL
|
||||||
|
elsif o =~ /^\W/
|
||||||
|
style = Nodes::Scalar::DOUBLE_QUOTED
|
||||||
else
|
else
|
||||||
unless String === @ss.tokenize(o)
|
unless String === @ss.tokenize(o)
|
||||||
style = Nodes::Scalar::SINGLE_QUOTED
|
style = Nodes::Scalar::SINGLE_QUOTED
|
||||||
|
@ -15,6 +15,11 @@ module Psych
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_doublequotes_when_there_is_a_single
|
||||||
|
yaml = Psych.dump "@123'abc"
|
||||||
|
assert_match(/---\s*"/, yaml)
|
||||||
|
end
|
||||||
|
|
||||||
def test_dash_dot
|
def test_dash_dot
|
||||||
assert_cycle '-.'
|
assert_cycle '-.'
|
||||||
assert_cycle '+.'
|
assert_cycle '+.'
|
||||||
|
Loading…
x
Reference in New Issue
Block a user