From e3fab1f37364c96d9c0207428bc857533918beba Mon Sep 17 00:00:00 2001 From: SHIBATA Hiroshi Date: Wed, 29 Nov 2017 14:58:59 +0900 Subject: Revert "Double quote stings that contain single quotes only" --- lib/psych/visitors/yaml_tree.rb | 2 +- test/psych/test_string.rb | 7 ------- 2 files changed, 1 insertion(+), 8 deletions(-) diff --git a/lib/psych/visitors/yaml_tree.rb b/lib/psych/visitors/yaml_tree.rb index f44e973..cfed8f1 100644 --- a/lib/psych/visitors/yaml_tree.rb +++ b/lib/psych/visitors/yaml_tree.rb @@ -304,7 +304,7 @@ module Psych quote = false elsif @line_width && o.length > @line_width style = Nodes::Scalar::FOLDED - elsif o =~ /^[^[:word:]][^"]*$/ or o =~ /^([^"]*'+[^"]*)+$/ + elsif o =~ /^[^[:word:]][^"]*$/ style = Nodes::Scalar::DOUBLE_QUOTED elsif not String === @ss.tokenize(o) or /\A0[0-7]*[89]/ =~ o style = Nodes::Scalar::SINGLE_QUOTED diff --git a/test/psych/test_string.rb b/test/psych/test_string.rb index e80d191..973f38b 100644 --- a/test/psych/test_string.rb +++ b/test/psych/test_string.rb @@ -37,13 +37,6 @@ module Psych assert_equal str, Psych.load(yaml) end - def test_doublequotes_when_there_are_single_quotes_only - str = "psych: Please don't escape ' with ' here." - yaml = Psych.dump str - assert_equal "--- \"psych: Please don't escape ' with ' here.\"\n", yaml - assert_equal str, Psych.load(yaml) - end - def test_plain_when_shorten_than_line_width_and_no_final_line_break str = "Lorem ipsum" yaml = Psych.dump str, line_width: 12 -- cgit v1.2.3