[英]Documentation for Psych to_yaml options?
Ruby 1.9.3 defaults to using Psych for YAML. Ruby 1.9.3默认使用Psych for YAML。 While the ruby-doc documentation for it is completely lacking , I was able to find one external piece of documentation that hinted that the
indentation
option is supported. 虽然它的ruby-doc文档 完全缺乏 ,但我能够找到一个外部文档,暗示支持
indentation
选项。 This was borne out in testing: 测试证实了这一点:
irb(main):001:0> RUBY_VERSION
#=> "1.9.3"
irb(main):002:0> require 'yaml'
#=> true
irb(main):003:0> [[[1]]].to_yaml
#=> "---\n- - - 1\n"
irb(main):009:0> [[[1]]].to_yaml indentation:9
#=> "---\n- - - 1\n"
There are presumably more options supported. 可能支持更多选项。 Specifically, I want to know how to change the line wrap width or disable it altogether.
具体来说,我想知道如何更改换行宽度或完全禁用它。
What are the options available? 有哪些选择?
Deep in the guts of ruby-1.9.3-p125/ext/psych/emitter.c
I found three options: 在
ruby-1.9.3-p125/ext/psych/emitter.c
我找到了三个选项:
indentation
- The level must be less than 10 and greater than 1. indentation
- 级别必须小于10且大于1。 line_width
- Set the preferred line width. line_width
- 设置首选线宽。 canonical
- Set the output style to canonical, or not (true/false). canonical
- 将输出样式设置为canonical,或者不设置(true / false)。 And they work! 他们工作!
如果要禁用换行,请使用此选项:
line_width: -1
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.