Class: Vagrant::Ruby::Command

Inherits:
Object
  • Object
show all
Defined in:
lib/vagrant-ruby.rb

Direct Known Subclasses

Ruby

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name) ⇒ Command



30
31
32
# File 'lib/vagrant-ruby.rb', line 30

def initialize(name)
  @name = name
end

Instance Attribute Details

#flagsObject (readonly)

Returns the value of attribute flags.



28
29
30
# File 'lib/vagrant-ruby.rb', line 28

def flags
  @flags
end

#nameObject (readonly)

Returns the value of attribute name.



27
28
29
# File 'lib/vagrant-ruby.rb', line 27

def name
  @name
end

Instance Method Details

#executeObject



53
54
55
56
57
58
# File 'lib/vagrant-ruby.rb', line 53

def execute
  with_clean_env do
    command = File.join(Gem.default_bindir, name)
    Process.exec([command, name], *flags)
  end
end

#new(flags, *_) ⇒ Object



34
35
36
37
# File 'lib/vagrant-ruby.rb', line 34

def new(flags, *_)
  @flags = flags
  self
end

#synopsisObject



39
40
41
# File 'lib/vagrant-ruby.rb', line 39

def synopsis
  "execute Vagrant's embedded #{name}"
end

#with_clean_envObject



43
44
45
46
47
48
49
50
51
# File 'lib/vagrant-ruby.rb', line 43

def with_clean_env
  if not defined? ::Bundler
    yield
  else
    ::Bundler.with_clean_env do
      yield
    end
  end
end