jm / toml

Parse TOML. Like a bawss.
MIT License
151 stars 37 forks source link

Given a hash, output toml #4

Closed johndbritton closed 11 years ago

johndbritton commented 11 years ago

It's great to be able to parse TOML, but I'd also like the ability to write out TOML. Any plans to support this?

dirk commented 11 years ago

Working on this right now. :smile:

jm commented 11 years ago

Looking good. BTW, let me know when I need to cut a new gem release to RubyGems. Maybe in the meantime I can figure out how to add you as a collaborator on there so you can push, too. :)

dirk commented 11 years ago

Will do. I still need to flesh out its TOML formatting conversions before it'll be release-ready. On that note, does adding a to_toml method to Strings, Integers, Floats, Arrays, etc. and then calling that from the generator sound okay? I can throw that together tonight/tomorrow morning.

jm commented 11 years ago

Hrmm. That sounds fine to me, but can we make them injected only if you require something like 'toml/generator' or something? That'd keep them from polluting the object space more than necessary.

dirk commented 11 years ago

Definitely. Should it auto-inject when you initialize a Generator for the first time? I'd personally rather it Just Work and do a little polluting when I try generating versus having to deal with another error message (even if it is informative and tells me exactly what to do).

jm commented 11 years ago

Yeah go ahead and fire them off when the file is required I'd say. It'll make things much cleaner.

dirk commented 11 years ago

Okay so faac21020b9207a09ff9fb2f16dad889ec4d350d adds the inject! class method to add the to_toml methods to the internal Ruby classes used by the generator. When you initialize a generator it calls this to ensure the to_toml methods that it needs are there. Do you think this should be split out into a separate file with regular class-and-method definitions or is the current style okay?

haileys commented 11 years ago

for the love of god do not add a to_toml method to anything

dirk commented 11 years ago

Why not? Doing so matches the behaviors of the JSON gem (to_json), YAML gem (to_yaml), MessagePack gem (to_msgpack), etc.

haileys commented 11 years ago

to_json has caused so much pain over the years

johndbritton commented 11 years ago

@dirk Are you still planning to work on this?

dirk commented 11 years ago

@johndbritton Sure! Just not sure what needs to be done. Any specific features/capabilities you'd like?

johndbritton commented 11 years ago

I was just looking for a way to go from a hash to toml that I can write out to a file. How ever you all decide to expose that is fine by me.

dirk commented 11 years ago

@johndbritton Check out test/test_generator.rb for usage of the generator. If that doesn't work with the current gem version then @jm can update it.

dirk commented 11 years ago

Just noticed that there are no usage examples for the generator in the README; will fix that.

dirk commented 11 years ago

Just pushed eb78127f7501d0f8e590f05e8571db1e72622d5e so closing this.

johndbritton commented 11 years ago

awesome, thanks. :beers: