Hello! I am wondering if there is a nice way of parsing mostly-structured YAML config, where the outermost layer contains YAML aliases?
This is easiest to explain with an example:
require "yaml" class Config include YAML::Serializable property foo : Int32 property bar : Int32 end config_per_environment = Hash(String, Config).from_yaml File.open("config.yml") puts config_per_environment["dev"]
defaults: &defaults foo: 17 dev: <<: *defaults bar: 54
This fails to parse as
defaults does not contain all the fields needed to be turned into a
Config - however all I want is to use it to avoid repetition, and will never read it as a
I could of course use
YAML::Any to parse the whole thing, but I would like some semblance of static typing here (to avoid having to manually verify the config at every step).
Any suggestions would be appreciated!