aboutsummaryrefslogtreecommitdiffstats
path: root/lib/yaml/rubytypes.rb
diff options
context:
space:
mode:
authorwhy <why@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2004-08-18 20:42:09 +0000
committerwhy <why@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2004-08-18 20:42:09 +0000
commit5e07e55204aede8b5f80e7d01b464f08c6bd611e (patch)
tree98e5b0c0eb7c6be16839d7c2afff34ed3089a6a2 /lib/yaml/rubytypes.rb
parentb79d77197f17778a9a63a9b048bd22194418007b (diff)
downloadruby-5e07e55204aede8b5f80e7d01b464f08c6bd611e.tar.gz
* lib/yaml/baseemitter.rb: folding now handles double-quoted strings,
fixed problem with extra line feeds at end of folding, whitespace opening scalar blocks. * lib/yaml/rubytypes.rb: subtelties in handling strings with non-printable characters and odd whitespace patterns. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@6787 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib/yaml/rubytypes.rb')
-rw-r--r--lib/yaml/rubytypes.rb14
1 files changed, 7 insertions, 7 deletions
diff --git a/lib/yaml/rubytypes.rb b/lib/yaml/rubytypes.rb
index bd91bc039d..47f591ea0c 100644
--- a/lib/yaml/rubytypes.rb
+++ b/lib/yaml/rubytypes.rb
@@ -1,5 +1,6 @@
# -*- mode: ruby; ruby-indent-level: 4; tab-width: 4 -*- vim: sw=4 ts=4
require 'date'
+require 'yaml/compat'
#
# Type conversions
#
@@ -315,25 +316,24 @@ class String
}
elsif self.is_binary_data?
out.binary_base64( self )
- # elsif self =~ /^ |#{YAML::ESCAPE_CHAR}| $/
- # complex = false
+ elsif self =~ /#{YAML::ESCAPE_CHAR}/
+ out.node_text( self, '"' )
else
out.node_text( self, to_yaml_fold )
end
- end
- if not complex
+ else
ostr = if out.options(:KeepValue)
self
elsif empty?
"''"
elsif self =~ /^[^#{YAML::WORD_CHAR}\/]| \#|#{YAML::ESCAPE_CHAR}|[#{YAML::SPACE_INDICATORS}]( |$)| $|\n|\'/
- "\"#{YAML.escape( self )}\""
+ out.node_text( self, '"' ); nil
elsif YAML.detect_implicit( self ) != 'str'
- "\"#{YAML.escape( self )}\""
+ out.node_text( self, '"' ); nil
else
self
end
- out.simple( ostr )
+ out.simple( ostr ) unless ostr.nil?
end
}
end