lib/yaml-write-stream/yielding.rb in yaml-write-stream-1.0.3 vs lib/yaml-write-stream/yielding.rb in yaml-write-stream-1.0.4
- old
+ new
@@ -49,17 +49,21 @@
emitter.end_mapping
end
protected
- def write_scalar(value)
+ def write_scalar(value, quote = false)
@first = 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 : ''
@@ -82,10 +86,10 @@
end
def write_key_value(key, value)
@first = false
write_scalar(key)
- write_scalar(value)
+ write_scalar(value, true)
end
end
class YieldingSequenceWriter < YieldingWriter
def write_element(element)