-
Notifications
You must be signed in to change notification settings - Fork 33
Description
On my investigation towards generating a yaml with sorted keys (#45), I realized that I need is the Dumper object used in lyaml/init.lua with a small tweak to the dump_mapping function.
It seems that the only way for me to accomplish this would be to copy-paste the whole implementation of dumper_mt.
I realize that this might be a philosophical point about design, but this feels "wrong" to me.
I see two approaches that would make this less painful:
- Option a) Exposing
DumperandParserdirectly in the lyaml library
local Dumper = require('lyaml').Dumper`)
Then I would be able to build/customize my custom dumper file easily.
This would be trivial to implement, but perhaps a bit "crude". It also opens the door for global modifications of the library (someone could decide to monkeypatch the global Dumper object, instead of using it to build a new Dumper object and using that).
- Option b) Allowing overriding specific dumper methods via the
optionsparameter
local str = lyaml.dump(tbl, { dump_mapping = my_custom_dump_mapping })
I... honestly don't see a lot of big drawbacks to this one. It seems simple to implement and can be done without exposing global variables for modification.
Would you be open to accepting a PR on any of these directions?