Project

General

Profile

Actions

Bug #10824

closed

to_yaml incorrectly inserts return lines

Added by cthielen (Christopher Thielen) about 9 years ago. Updated almost 5 years ago.

Status:
Closed
Target version:
-
ruby -v:
ruby 2.1.5p273 (2014-11-13 revision 48405) [x86_64-darwin14.0]
[ruby-core:67985]

Description

"{\"config_path\":\"something\",\"mode\":\"something_underscore\",\"person\":{\"id\":1,\"name\":\"Christopher Michael Thielen\",\"address\":\"First Shields Ave\"}}".to_yaml

returns:

"--- '{\"config_path\":\"something\",\"mode\":\"something_underscore\",\"person\":{\"id\":1,\"name\":\"Christopher\n  Michael Thielen\",\"address\":\"First Shields Ave\"}}'\n"

Note that a newline has been inserted after the word ‘Christopher’. It shouldn’t be there.

Curiously enough, if we leave out, say, the “mode” key, the newline shifts around:

"{\"config_path\":\"something\",\"person\":{\"id\":1,\"name\":\"Christopher Michael Thielen\",\"address\":\"First Shields Ave\"}}".to_yaml

returns:

"--- '{\"config_path\":\"something\",\"person\":{\"id\":1,\"name\":\"Christopher Michael Thielen\",\"address\":\"First\n  Shields Ave\"}}'\n"

Note that the newline isn’t after ‘Christopher' anymore but is after the word ‘First’.

This functionality appears in at least:

ruby 2.0.0p353 (2013-11-22 revision 43784) [x86_64-darwin12.5.0]

and

ruby 2.1.5p273 (2014-11-13 revision 48405) [x86_64-darwin14.0]

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0