Class: Flock::Sandbox::Runner

Inherits:
Object
  • Object
show all
Defined in:
lib/flock/sandbox.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(args) ⇒ Runner

Returns a new instance of Runner.



17
18
19
# File 'lib/flock/sandbox.rb', line 17

def initialize(args)
  self.config_path, self.target = args
end

Instance Attribute Details

#config_pathObject

Returns the value of attribute config_path.



16
17
18
# File 'lib/flock/sandbox.rb', line 16

def config_path
  @config_path
end

#definitionObject

Returns the value of attribute definition.



16
17
18
# File 'lib/flock/sandbox.rb', line 16

def definition
  @definition
end

#targetObject

Returns the value of attribute target.



16
17
18
# File 'lib/flock/sandbox.rb', line 16

def target
  @target
end

Instance Method Details

#define(&blk) ⇒ Object



33
34
35
36
37
# File 'lib/flock/sandbox.rb', line 33

def define(&blk)
  self.definition = Definition.new
  context = Context.new(self, definition)
  context.instance_exec(definition, &blk)
end

#runObject



21
22
23
24
25
26
27
28
29
30
31
# File 'lib/flock/sandbox.rb', line 21

def run
  instance_eval(File.open(config_path).read, config_path)
  case target
  when "docker"
    Docker.new(definition).run
  when "vagrant"
    Vagrant.new(definition).run
  when "docker-stop"
    DockerStop.new(definition).run
  end
end