I am using YAML for configuration files, which can be hand edited or
modified by software. I would like the comments to survive across a
load/store. Something along these lines:
Conf file:
Set to your liking
personal_salary: “too small”
Default should be OK
others_salary: “too much”
Change only if you know what you are doing™
boss_salary: “insane”
Code example:
$conf, $com = YAML::load(File.open("/path/to/conf"))
-> $conf = { “personal_salary” => “too small”, … }
$com = { “personal_salary” => “Set to your liking”, … }
$conf[“personal_salary”] = “much better"
File.open(”/path/to/conf", “w”).puts($conf.to_yaml(“comments” => $com))
Gives:
Set to your liking
personal_salary: “much better”
Default should be OK
others_salary: “too much”
Change only if you know what you are doing™
boss_salary: “insane”
Is that a doable/interesting feature? Can it be done with the existing
parser or should the syck C code be modified to?
Guillaume.