Sha256: c8f2aea495529d1d9b894be49a4d1500014688cc63c109d7132ca2ae6c86a44f

Contents?: true

Size: 1017 Bytes

Versions: 2

Compression:

Stored size: 1017 Bytes

Contents

require 'set'

module VagrantPlugins
  module Vocker
    class Config < Vagrant.plugin("2", :config)
      attr_reader :images, :containers
      attr_accessor :version

      def initialize
        @images     = Set.new
        @containers = Hash.new
        @version    = :latest
      end

      def pull_images(*images)
        @images += images.map(&:to_s)
      end

      def run(*args)
        container_name = args.shift
        params         = {}

        if args.empty?
          params[:image] = container_name
        elsif args.first.is_a?(String)
          params[:image] = args.shift
          params[:cmd]   = container_name
        else
          params = args.shift
          params[:cmd] ||= container_name
        end

        # TODO: Validate provided parameters before assignment
        @containers[container_name.to_s] = params
      end

      def merge(other)
        super.tap do |result|
          result.pull_images *(other.images + self.images)
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
vocker-0.4.1 lib/vocker/config.rb
vocker-0.4.0 lib/vocker/config.rb