* ext/psych/lib/psych/visitors/yaml_tree.rb: use literal YAML style
when emitting multi-line strings. Thanks @atambo * test/psych/test_yaml.rb: test for change. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37698 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
24c6a7c368
commit
653b0bcbaf
@ -1,3 +1,10 @@
|
|||||||
|
Sat Nov 17 12:14:50 2012 Aaron Patterson <aaron@tenderlovemaking.com>
|
||||||
|
|
||||||
|
* ext/psych/lib/psych/visitors/yaml_tree.rb: use literal YAML style
|
||||||
|
when emitting multi-line strings. Thanks @atambo
|
||||||
|
|
||||||
|
* test/psych/test_yaml.rb: test for change.
|
||||||
|
|
||||||
Sat Nov 17 12:03:41 2012 Aaron Patterson <aaron@tenderlovemaking.com>
|
Sat Nov 17 12:03:41 2012 Aaron Patterson <aaron@tenderlovemaking.com>
|
||||||
|
|
||||||
* ext/psych/lib/psych/scalar_scanner.rb: avoid raising exceptions when
|
* ext/psych/lib/psych/scalar_scanner.rb: avoid raising exceptions when
|
||||||
|
@ -231,15 +231,18 @@ module Psych
|
|||||||
plain = false
|
plain = false
|
||||||
quote = false
|
quote = false
|
||||||
style = Nodes::Scalar::ANY
|
style = Nodes::Scalar::ANY
|
||||||
|
tag = nil
|
||||||
|
str = o
|
||||||
|
|
||||||
if binary?(o)
|
if binary?(o)
|
||||||
str = [o].pack('m').chomp
|
str = [o].pack('m').chomp
|
||||||
tag = '!binary' # FIXME: change to below when syck is removed
|
tag = '!binary' # FIXME: change to below when syck is removed
|
||||||
#tag = 'tag:yaml.org,2002:binary'
|
#tag = 'tag:yaml.org,2002:binary'
|
||||||
style = Nodes::Scalar::LITERAL
|
style = Nodes::Scalar::LITERAL
|
||||||
|
elsif o =~ /\n/
|
||||||
|
quote = true
|
||||||
|
style = Nodes::Scalar::LITERAL
|
||||||
else
|
else
|
||||||
str = o
|
|
||||||
tag = nil
|
|
||||||
quote = !(String === @ss.tokenize(o))
|
quote = !(String === @ss.tokenize(o))
|
||||||
plain = !quote
|
plain = !quote
|
||||||
end
|
end
|
||||||
|
@ -1266,4 +1266,9 @@ EOY
|
|||||||
Psych.load("2000-01-01 00:00:00.#{"0"*1000} +00:00\n")
|
Psych.load("2000-01-01 00:00:00.#{"0"*1000} +00:00\n")
|
||||||
# '[ruby-core:13735]'
|
# '[ruby-core:13735]'
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_multiline_string_uses_literal_style
|
||||||
|
yaml = Psych.dump("multi\nline\nstring")
|
||||||
|
assert_match("|", yaml)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user