Module: Vagrant::DSL::GenericMixin

Included in:
Vagrant::DSL, Prison
Defined in:
lib/vagrant/dsl.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#envObject

Returns the value of attribute env.



48
49
50
# File 'lib/vagrant/dsl.rb', line 48

def env
  @env
end

#ui_classObject



54
55
56
# File 'lib/vagrant/dsl.rb', line 54

def ui_class
  @ui_class || Vagrant::UI::Basic
end

Instance Method Details

#construct_envObject



50
51
52
# File 'lib/vagrant/dsl.rb', line 50

def construct_env
  Vagrant::Environment.new(:ui_class => ui_class)
end

#vagrant(command, *args, &block) ⇒ Object



71
72
73
74
75
76
# File 'lib/vagrant/dsl.rb', line 71

def vagrant(command, *args, &block)
  self.env ||= construct_env
  Vagrant.commands[command.to_sym].new(args, env).execute
rescue SystemExit => e # vagrant calls exit a lot
  return e.status
end

#vagrant_captureObject



58
59
60
61
62
63
64
65
66
67
68
69
# File 'lib/vagrant/dsl.rb', line 58

def vagrant_capture
  old_ui_class = ui_class
  self.ui_class = Vagrant::UI::Captured
  self.env = construct_env
  yield
  stdout = env.ui.stdout.string
  stderr = env.ui.stderr.string
  self.ui_class = old_ui_class
  self.env = construct_env

  return stdout, stderr
end