lib/yaml-write-stream/stateful.rb in yaml-write-stream-1.0.3 vs lib/yaml-write-stream/stateful.rb in yaml-write-stream-1.0.4

- old
+ new

@@ -112,15 +112,19 @@ def current stack.last end - def write_scalar(value) + def write_scalar(value, quote = false) style = if value == '' Psych::Nodes::Scalar::DOUBLE_QUOTED else - Psych::Nodes::Scalar::ANY + if !quote || !value + Psych::Nodes::Scalar::ANY + else + Psych::Nodes::Scalar::DOUBLE_QUOTED + end end quoted = value == '' value = value ? value : '' @@ -147,10 +151,10 @@ write_scalar(key) end def write_key_value(key, value) write_scalar(key) - write_scalar(value) + write_scalar(value, true) end def close emitter.end_mapping end