Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Preserve hash structure when generating a TOML file #70

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

pinecat
Copy link

@pinecat pinecat commented Feb 13, 2022

For a given hash, preserve its structure when generating the TOML doc
string (via TOML::Generator.new(hash).body). To do this, you would pass
in a boolean with the constructor for TOML::Generator.

body = Generator.new(doc, false).body # Creates a TOML string that sorts the hash keys of 'doc'
body = Generator.new(doc, true).body # Creates a TOML string which preserves the structure of the the hash, 'doc'

The default value is false, mimicking the current behavior.

body = Generator.new(doc).body # Creates a TOML string that sorts the hash keys of 'doc'

Fixes #69.

For a given hash, preserve its structure when generating the TOML doc
string (via TOML::Generator.new(hash).body).  To do this, you would pass
in a boolean with the contstructor for TOML::Generator:

body = Generator.new(hash, true).body

The default value is false, mimicking the current behavior.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Feature: Preserve hash strructure when generating a TOML file
1 participant