savonrb / gyoku

Translates Ruby Hashes to XML
MIT License
231 stars 58 forks source link

Allow to prettify XML #59

Closed Jeiwan closed 8 years ago

Jeiwan commented 8 years ago

This PR adds :pretty_print, :indent and :compact options to allow prettified XML output. There is an old PR https://github.com/savonrb/gyoku/pull/35 that has the same purpose, but it stumbled over problems in Builder gem. In this PR I don't mess with Builder gem but instead use REXML from standard Ruby library to format generated XML. Prettifying doesn't work for XML documents generated from an array without unwrap option set to true as such documents are not valid and cannot be formatted by REXML. This case is just bypassed, no exceptions thrown.

tjarratt commented 8 years ago

Thanks @Jeiwan !

xuanyu-h commented 8 years ago

Please build a new version gem and push it to rubygems.org, thanks