summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorAaron Patterson <aaron.patterson@gmail.com>2013-02-07 15:55:03 -0800
committerAaron Patterson <aaron.patterson@gmail.com>2013-02-07 15:55:03 -0800
commit69a1aea11b5687a500d0901e7513691766ce80d4 (patch)
tree655eaccf69aae11d209775f51e7d8acc5ff7648e /lib
parent4ed9ce4792090b63b43ae7b5f298f18c60954e43 (diff)
downloadpsych-69a1aea11b5687a500d0901e7513691766ce80d4.tar.gz
* ext/psych/lib/psych/visitors/yaml_tree.rb: fixing string quotation
when dumping Ruby strings. Thanks Ingy * test/psych/test_psych.rb: appropriate tests. * test/psych/test_yaml.rb: ditto
Diffstat (limited to 'lib')
-rw-r--r--lib/psych/visitors/yaml_tree.rb17
1 files changed, 8 insertions, 9 deletions
diff --git a/lib/psych/visitors/yaml_tree.rb b/lib/psych/visitors/yaml_tree.rb
index 53cbad3..6b6a5ff 100644
--- a/lib/psych/visitors/yaml_tree.rb
+++ b/lib/psych/visitors/yaml_tree.rb
@@ -253,9 +253,9 @@ module Psych
private :binary?
def visit_String o
- plain = false
- quote = false
- style = Nodes::Scalar::ANY
+ plain = true
+ quote = true
+ style = Nodes::Scalar::PLAIN
tag = nil
str = o
@@ -264,15 +264,14 @@ module Psych
tag = '!binary' # FIXME: change to below when syck is removed
#tag = 'tag:yaml.org,2002:binary'
style = Nodes::Scalar::LITERAL
+ plain = false
+ quote = false
elsif o =~ /\n/
- quote = true
style = Nodes::Scalar::LITERAL
- elsif o =~ /^\W/
- quote = true
- style = Nodes::Scalar::DOUBLE_QUOTED
else
- quote = !(String === @ss.tokenize(o))
- plain = !quote
+ unless String === @ss.tokenize(o)
+ style = Nodes::Scalar::SINGLE_QUOTED
+ end
end
ivars = find_ivars o