Class: VagrantPlugins::Vocker::Config

Inherits:
Object
  • Object
show all
Defined in:
lib/vocker/config.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfig

Returns a new instance of Config.



9
10
11
12
13
# File 'lib/vocker/config.rb', line 9

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

Instance Attribute Details

#containersObject (readonly)

Returns the value of attribute containers.



6
7
8
# File 'lib/vocker/config.rb', line 6

def containers
  @containers
end

#imagesObject (readonly)

Returns the value of attribute images.



6
7
8
# File 'lib/vocker/config.rb', line 6

def images
  @images
end

#versionObject

Returns the value of attribute version.



7
8
9
# File 'lib/vocker/config.rb', line 7

def version
  @version
end

Instance Method Details

#merge(other) ⇒ Object



37
38
39
40
41
# File 'lib/vocker/config.rb', line 37

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

#pull_images(*images) ⇒ Object



15
16
17
# File 'lib/vocker/config.rb', line 15

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

#run(*args) ⇒ Object



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/vocker/config.rb', line 19

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