You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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 Dumper and Parser directly 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 options parameter
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?
The text was updated successfully, but these errors were encountered:
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 thedump_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:
Dumper
andParser
directly in the lyaml libraryThen 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).
options
parameterI... 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?
The text was updated successfully, but these errors were encountered: