Class: Vx::Lib::Container::Local

Inherits:
Object
  • Object
show all
Includes:
Instrument
Defined in:
lib/vx/lib/container/local.rb,
lib/vx/lib/container/local/spawner.rb

Defined Under Namespace

Classes: Spawner

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Instrument

#instrument

Constructor Details

#initialize(options = {}) ⇒ Local

Returns a new instance of Local.



14
15
16
17
# File 'lib/vx/lib/container/local.rb', line 14

def initialize(options = {})
  @work_dir = options[:work_dir] || default_work_dir
  @work_dir = File.expand_path(@work_dir)
end

Instance Attribute Details

#work_dirObject (readonly)

Returns the value of attribute work_dir.



12
13
14
# File 'lib/vx/lib/container/local.rb', line 12

def work_dir
  @work_dir
end

Instance Method Details

#start(&block) ⇒ Object



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/vx/lib/container/local.rb', line 19

def start(&block)
  instrument( "create", container_type: 'local', container: { work_dir: work_dir }) do
    FileUtils.rm_rf(work_dir)
    FileUtils.mkdir_p(work_dir)
  end

  begin
    spawner = Spawner.new(work_dir)
    yield spawner
  ensure
    instrument( "kill", container_type: 'local', container: { work_dir: work_dir }) do
      FileUtils.mkdir_p(work_dir)
    end
  end
end