Class: VagrantPlugins::ProxyConf::Plugin

Inherits:
Vagrant::Plugin::V2::Plugin
  • Object
show all
Defined in:
lib/vagrant-proxyconf/plugin.rb,
lib/vagrant-proxyconf/plugin.rb

Overview

Vagrant Plugin class that registers all proxy configs, hooks, etc.

Constant Summary collapse

MIN_VAGRANT_VERSION =

The minimum compatible Vagrant version

'1.2.0'
OPTIONAL_PLUGIN_DEPENDENCIES =

A list of plugins whose action classes we hook to if installed

%w[vagrant-aws vagrant-omnibus vagrant-vbguest]

Class Method Summary collapse

Class Method Details

.check_vagrant_version!Object

Verifies that the Vagrant version fulfills the requirements

is incompatible with the Vagrant version

Raises:

  • (VagrantPlugins::ProxyConf::VagrantVersionError)

    if this plugin



19
20
21
22
23
24
25
# File 'lib/vagrant-proxyconf/plugin.rb', line 19

def self.check_vagrant_version!
  if Gem::Version.new(Vagrant::VERSION) < Gem::Version.new(MIN_VAGRANT_VERSION)
    msg = I18n.t('vagrant_proxyconf.errors.vagrant_version', min_version: MIN_VAGRANT_VERSION)
    $stderr.puts msg
    raise msg
  end
end

.load_optional_dependenciesObject

Loads the plugins to ensure their action hooks are registered before us. Uses alphabetical order to not change the default behaviour otherwise.



45
46
47
# File 'lib/vagrant-proxyconf/plugin.rb', line 45

def self.load_optional_dependencies
  OPTIONAL_PLUGIN_DEPENDENCIES.sort.each { |plugin| load_optional_dependency plugin }
end

.load_optional_dependency(plugin) ⇒ Object

Ensures a dependent plugin is loaded before us if it is installed. Ignores Vagrant::Errors::PluginLoadError but passes other exceptions.

Parameters:

  • plugin (String)

    the plugin name



37
38
39
40
41
# File 'lib/vagrant-proxyconf/plugin.rb', line 37

def self.load_optional_dependency(plugin)
  begin
    Vagrant.require_plugin plugin
  rescue Vagrant::Errors::PluginLoadError; end
end

.setup_i18nObject

Initializes the internationalization strings



28
29
30
31
# File 'lib/vagrant-proxyconf/plugin.rb', line 28

def self.setup_i18n
  I18n.load_path << File.expand_path('../../../locales/en.yml', __FILE__)
  I18n.reload!
end