Sha256: 6cf3fbfa36a00e38e37c75825d2f6c6e785a9764e5da24e7073429318f8c1e04

Contents?: true

Size: 895 Bytes

Versions: 7

Compression:

Stored size: 895 Bytes

Contents

require 'set'

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

      def initialize
        @images     = Set.new
        @containers = Hash.new
      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

        @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

7 entries across 7 versions & 1 rubygems

Version Path
vocker-0.3.3 lib/vocker/config.rb
vocker-0.3.2 lib/vocker/config.rb
vocker-0.3.1 lib/vocker/config.rb
vocker-0.3.0 lib/vocker/config.rb
vocker-0.2.1 lib/vocker/config.rb
vocker-0.2.0 lib/vocker/config.rb
vocker-0.1.0 lib/vocker/config.rb