Class: VagrantPlugins::ProxyConf::Plugin
- Inherits:
-
Vagrant::Plugin::V2::Plugin
- Object
- Vagrant::Plugin::V2::Plugin
- VagrantPlugins::ProxyConf::Plugin
- 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
-
.check_vagrant_version! ⇒ Object
Verifies that the Vagrant version fulfills the requirements.
-
.load_optional_dependencies ⇒ Object
Loads the plugins to ensure their action hooks are registered before us.
-
.load_optional_dependency(plugin) ⇒ Object
Ensures a dependent plugin is loaded before us if it is installed.
-
.setup_i18n ⇒ Object
Initializes the internationalization strings.
Class Method Details
.check_vagrant_version! ⇒ Object
Verifies that the Vagrant version fulfills the requirements
is incompatible with the Vagrant version
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_dependencies ⇒ Object
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.
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_i18n ⇒ Object
Initializes the internationalization strings
28 29 30 31 |
# File 'lib/vagrant-proxyconf/plugin.rb', line 28 def self.setup_i18n I18n.load_path << File.('../../../locales/en.yml', __FILE__) I18n.reload! end |