I would like to make something similar to an hypothetical INI::Serializable, which will use the stdlib to parse an INI IO/String and set instance variable accordingly.
INI.parse returns a Hash(String, Hash(String, String)), which allows to do more or less what I want, except two things that can be better:
The line number is useful to raise an exception to the user, with as information the invalid key and its line.
Yielding each section, key, value and number is not possible because empty sections can exist.
A simple pull parser can be an option, or having a INI.parse which can yield a Section | Key union object (a line can either be a section declaration or a key/value).
I think INI.build is fine, because it accepts any object which implements each, with values that also implements #each.
One little issue is that the main object has also to implement #[], to check if there is a empty section at first. It can be solved by using is_a? Hash.
Also it might be worth to show TOML some love which is essentially a well defined superset of INI.
INI is very widely used for configuration, where JSON is considered not readable enough and YAML too complicated.
Examples of applications using it: Gitea, Minetest, PHP.
A lot of Linux applications are using it for configuration (as .conf or .ini) in $XDG_CONFIG_HOME and in /etc: VLC, Geany, LibreOffice, LXQt.
A lot of languages have it in their stdlib.
It is ok for me to propose a INI::PullParser PR.
Most helpful comment
Also it might be worth to show TOML some love which is essentially a well defined superset of INI.