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

Version Path
cloulu-1.0.0 lib/manifests-vmc-plugin/loader/builder.rb
cloulu-0.7.0 lib/manifests-vmc-plugin/loader/builder.rb
cloulu-0.6.6 lib/manifests-vmc-plugin/loader/builder.rb
cloulu-0.6.5 lib/manifests-vmc-plugin/loader/builder.rb
cloulu-0.6.1 lib/manifests-vmc-plugin/loader/builder.rb
cloulu-0.6.0 lib/manifests-vmc-plugin/loader/builder.rb
cloulu-0.5.1 lib/manifests-vmc-plugin/loader/builder.rb
cloulu-0.5.0 lib/manifests-vmc-plugin/loader/builder.rb
cloulu-0.3.0 lib/manifests-vmc-plugin/loader/builder.rb
cloulu-0.2.6 lib/manifests-vmc-plugin/loader/builder.rb
cloulu-0.2.5 lib/manifests-vmc-plugin/loader/builder.rb
cloulu-0.2.4 lib/manifests-vmc-plugin/loader/builder.rb
cloulu-0.2.3 lib/manifests-vmc-plugin/loader/builder.rb
cloulu-0.2.1 lib/manifests-vmc-plugin/loader/builder.rb
cloulu-0.2.0 lib/manifests-vmc-plugin/loader/builder.rb
cloulu-0.1.6 lib/manifests-vmc-plugin/loader/builder.rb
cloulu-0.1.5 lib/manifests-vmc-plugin/loader/builder.rb
cloulu-0.1.2 lib/manifests-vmc-plugin/loader/builder.rb
cloulu-0.1.1 lib/manifests-vmc-plugin/loader/builder.rb
static-1.0.3 vendor/manifests-vmc-plugin-0.6.2/lib/manifests-vmc-plugin/loader/builder.rb