Sha256: 934e686a3b71f773c6eb1becb1d4124727d8ced86eb9a0399e249b2334a71544

Contents?: true

Size: 1.09 KB

Versions: 159

Compression:

Stored size: 1.09 KB

Contents

module VMC::Cli::Command
  class Manifest < Base
    include VMC::Cli::ManifestHelper

    def initialize(options)
      super

      # don't resolve any of the manifest template stuff
      if manifest_file
        @manifest = load_manifest_structure manifest_file
      else
        @manifest = {}
      end
    end

    def edit
      build_manifest
      save_manifest
    end

    def extend(which)
      parent = load_manifest_structure which
      @manifest = load_manifest_structure which

      build_manifest

      simplify(@manifest, parent)

      @manifest["inherit"] ||= []
      @manifest["inherit"] << which

      save_manifest(ask("Save where?"))
    end

    private

    def simplify(child, parent)
      return unless child.is_a?(Hash) and parent.is_a?(Hash)

      child.reject! do |k, v|
        if v == parent[k]
          puts "rejecting #{k}"
          true
        else
          simplify(v, parent[k])
          false
        end
      end
    end

    def build_manifest
      @application = ask("Configure for which application?", :default => ".")
      interact true
    end
  end
end

Version data entries

159 entries across 159 versions & 11 rubygems

Version Path
vmc-0.4.0.beta.49 vmc/lib/cli/commands/manifest.rb
vmc-0.4.0.beta.48 vmc/lib/cli/commands/manifest.rb
vmc-0.4.0.beta.47 vmc/lib/cli/commands/manifest.rb
vmc-0.3.21 lib/cli/commands/manifest.rb
vmc-0.4.0.beta.46 vmc/lib/cli/commands/manifest.rb
vmc-0.3.20 lib/cli/commands/manifest.rb
vmc-0.4.0.beta.45 vmc/lib/cli/commands/manifest.rb
vmc-0.4.0.beta.44 vmc/lib/cli/commands/manifest.rb
vmc-0.4.0.beta.43 vmc/lib/cli/commands/manifest.rb
vmc-0.4.0.beta.42 vmc/lib/cli/commands/manifest.rb
vmc-0.3.19 lib/cli/commands/manifest.rb
vmc-0.4.0.beta.41 vmc/lib/cli/commands/manifest.rb
vmc-0.4.0.beta.40 vmc/lib/cli/commands/manifest.rb
vmc-0.4.0.beta.39 vmc/lib/cli/commands/manifest.rb
vmc-0.4.0.beta.38 vmc/lib/cli/commands/manifest.rb
vmc-0.4.0.beta.37 vmc/lib/cli/commands/manifest.rb
vmc-0.4.0.beta.36 vmc/lib/cli/commands/manifest.rb
vmc-0.4.0.beta.35 vmc/lib/cli/commands/manifest.rb
vmc-0.4.0.beta.34 vmc/lib/cli/commands/manifest.rb
vmc-0.4.0.beta.33 vmc/lib/cli/commands/manifest.rb