Class: VagrantPlugins::Multiplug::Dependency

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, version = nil) ⇒ Dependency

Returns a new instance of Dependency.



18
19
20
21
# File 'lib/vagrant_plugins/multiplug/config.rb', line 18

def initialize(name, version = nil)
  @name = name
  @version = version
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



16
17
18
# File 'lib/vagrant_plugins/multiplug/config.rb', line 16

def name
  @name
end

#versionObject (readonly)

Returns the value of attribute version.



16
17
18
# File 'lib/vagrant_plugins/multiplug/config.rb', line 16

def version
  @version
end

Instance Method Details

#installed?Boolean

Note:

::Vagrant.has_plugin?(@name, @version) cannot be used because it looks up from caches

Returns:

  • (Boolean)


24
25
26
27
28
29
30
31
32
# File 'lib/vagrant_plugins/multiplug/config.rb', line 24

def installed?
  `vagrant plugin list`.each_line.any? do |line|
    if @version
      line == "#{@name} (#{@version})\n"
    else
      line.start_with?("#{@name} (")
    end
  end
end

#optionsString

Returns Command-line options for ‘vagrant plugin install NAME`.

Returns:

  • (String)

    Command-line options for ‘vagrant plugin install NAME`



35
36
37
38
39
# File 'lib/vagrant_plugins/multiplug/config.rb', line 35

def options
  if @version
    "--plugin-version #{@version}"
  end
end