Module: Nvvm::Validator

Included in:
Cli
Defined in:
lib/nvvm/validator.rb

Constant Summary collapse

METHOD_MAP =
{
  install: %w[version? git? new_version?],
  update: %w[git?],
  reinstall: %w[git? installed_version?],
  rebuild: %w[version? git? installed_version?],
  use: %w[version? installed_version?],
  list: %w[git?],
  uninstall: %w[version? installed_version?]
}.freeze

Class Method Summary collapse

Class Method Details

.git?Boolean

Returns:

  • (Boolean)


23
24
25
26
# File 'lib/nvvm/validator.rb', line 23

def git?
  abort 'git is required to install.' unless find_executable('git')
  true
end

.installed_version?(ver = version) ⇒ Boolean

Returns:

  • (Boolean)


40
41
42
43
# File 'lib/nvvm/validator.rb', line 40

def installed_version?(ver = version)
  abort "#{ver} is not installed." unless version_include?(ver)
  true
end

.new_version?(ver = nil) ⇒ Boolean

Returns:

  • (Boolean)


33
34
35
36
37
38
# File 'lib/nvvm/validator.rb', line 33

def new_version?(ver = nil)
  Installer.pull
  ver = version if ver.nil?
  abort "#{ver} is already installed." if version_include?(ver)
  true
end

.validate_before_invoke(command) ⇒ Object



17
18
19
20
21
# File 'lib/nvvm/validator.rb', line 17

def validate_before_invoke(command)
  return unless validations = METHOD_MAP[command.to_sym]

  validations.each { |v| send(v) }
end

.version?Boolean

Returns:

  • (Boolean)


28
29
30
31
# File 'lib/nvvm/validator.rb', line 28

def version?
  abort 'undefined Neovim version. please run [ nvvm list ].' if find_version.nil?
  true
end