why does psych yaml interpreter add line breaks around 80 characters?
You'll have to configure psych’s #to_yaml options. You'll most likely find it here:
ruby-1.9.3-p125/ext/psych/emitter.c
And then you can do something like this:
yaml.to_yaml(options = {:line_width => -1})
Writing to YAML file with File.open wraps longer lines
Turns out this was actually answered previously in "why does psych yaml interpreter add line breaks around 80 characters?". I was searching for the wrong thing.
Doing something like
yaml.to_yaml(:options => {:line_width => -1})
keeps the lines from wrapping.
Why i'm getting Psych::SyntaxError while translating YAML data back into working objects
You're missing some indentation. YML isn't white space agnostic. Try using this data instead:
yaml_string = <<END_OF_DATA
---
- !ruby/object:Person
age: 45
name: Jimmy
- !ruby/object:Person
age: 23
name: Laura Smith
END_OF_DATA
Documentation for Psych to_yaml options?
Deep in the guts of ruby-1.9.3-p125/ext/psych/emitter.c
I found three options:
indentation
- The level must be less than 10 and greater than 1.line_width
- Set the preferred line width.canonical
- Set the output style to canonical, or not (true/false).
And they work!
Why the difference in behavior of YAML parsers (syck and psych)?
As @matt had mentioned, the answer is this pull request: https://github.com/ruby/ruby/commit/9f688d53c2b5af5960d1e8d8fb09b26aa9d8b5f9
Related Topics
Celluloid Async Inside Ruby Blocks Does Not Work
What Purpose Can Anonymous Modules Serve
How to Do a Before_Action in Ruby (Like in Rails)
Using Authlogic_API for Rails Rest API Access
Using Negative Conditions Within Regular Expressions
Set Compression Level When Generating a Zip File Using Rubyzip
Using %I and %I Symbol Array Literal
Preventing Delayed_Job Background Jobs from Consuming Too Much CPU on a Single Server
Does Anyone Know How to Appropriately Deal with User Timezones in Rails 2.3
Instance Variables Inheritance
What the Purpose of Bind/Unbind Methods in Ruby
How to Upload a Local File to a Carrierwave Model
How to Use Coffeescript in the Views Executed on Render.Js
Gem Install Dm-Postgres-Adapter Build Error
Heroku and @Font-Face - Embedded Fonts Wont Display on Heroku
How to Make a Custom Environment in Rails a Default Environment