Permalink
Browse files

* ext/psych/lib/psych/visitors/yaml_tree.rb: use double quotes when

  strings start with special characters.
  [Fixes GH-157] #157

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

Fixes #157
  • Loading branch information...
1 parent 02f0498 commit 684612c46ee5534904fb811bc3548219fc38ea26 @tenderlove tenderlove committed Sep 5, 2013
Showing with 15 additions and 0 deletions.
  1. +8 −0 CHANGELOG.rdoc
  2. +2 −0 lib/psych/visitors/yaml_tree.rb
  3. +5 −0 test/psych/test_string.rb
View
@@ -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.
+
Thu Aug 29 02:40:45 2013 Aaron Patterson <aaron@tenderlovemaking.com>
* ext/psych/lib/psych/scalar_scanner.rb: invalid floats should be
@@ -288,6 +288,8 @@ def visit_String o
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
@@ -15,6 +15,11 @@ def initialize
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 '+.'

0 comments on commit 684612c

Please sign in to comment.