Sha256: a277a52a210ae0ba36bd24ab7126d06d236ea918e3ec6fcaaee4fa156ea24a93
Contents?: true
Size: 750 Bytes
Versions: 34
Compression:
Stored size: 750 Bytes
Contents
module VMCManifests module Builder # parse a manifest and merge with its inherited manifests def build(file) manifest = YAML.load_file file Array(manifest["inherit"]).each do |path| manifest = merge_parent(path, manifest) end manifest end private # merge the manifest at `parent_path' into the `child' def merge_parent(parent_path, child) merge_manifest(build(from_manifest(parent_path)), child) end # deep hash merge def merge_manifest(parent, child) merge = proc do |_, old, new| if new.is_a?(Hash) && old.is_a?(Hash) old.merge(new, &merge) else new end end parent.merge(child, &merge) end end end
Version data entries
34 entries across 34 versions & 4 rubygems