Class: VagrantPlugins::TimeZone::Plugin

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

Overview

Vagrant Plugin class that registers configs, hooks, etc.

Constant Summary collapse

VAGRANT_VERSION_REQUIREMENT =

Compatible Vagrant versions

'>= 1.2.0'.freeze

Class Method Summary collapse

Class Method Details

.check_vagrant_version(*requirements) ⇒ Boolean

Returns true if the Vagrant version fulfills the requirements

Parameters:

  • requirements (String, Array<String>)

    the version requirement

Returns:

  • (Boolean)


17
18
19
20
21
# File 'lib/vagrant-timezone/plugin.rb', line 17

def self.check_vagrant_version(*requirements)
  Gem::Requirement.new(*requirements).satisfied_by?(
    Gem::Version.new(Vagrant::VERSION)
  )
end

.check_vagrant_version!Object

Verifies that the Vagrant version fulfills the requirements

is incompatible with the Vagrant version

Raises:

  • (VagrantPlugins::TimeZone::VagrantVersionError)

    if this plugin



27
28
29
30
31
32
33
34
35
36
# File 'lib/vagrant-timezone/plugin.rb', line 27

def self.check_vagrant_version!
  return if check_vagrant_version(VAGRANT_VERSION_REQUIREMENT)

  msg = I18n.t(
    'vagrant_timezone.errors.vagrant_version',
    requirement: VAGRANT_VERSION_REQUIREMENT.inspect
  )
  warn msg
  raise msg
end

.setup_i18nObject

Initializes the internationalization strings



39
40
41
42
# File 'lib/vagrant-timezone/plugin.rb', line 39

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