I am writing a yaml file as follows:
File.open('output.yaml', 'w') do |f|
The content within the written file uses 2 spaces for indentation. How can I change the number of spaces? Say I want 4 spaces instead of 2, can this be done? I couldn't find any solution to do this, other than processing the whole file after writing the yaml.
You could pass options to Psych (psych is the default yamler):
File.open('output.yaml', 'w') do |f| YAML::dump(yaml, f, indentation: 4) end