Sha256: 4c18f174650204c52c01228f33774b8359f6cce59cb83e4c8b1b70328e5a921a

Contents?: true

Size: 1.01 KB

Versions: 7

Compression:

Stored size: 1.01 KB

Contents

module Validator
  module_function

  def check_hg
    unless Kernel.system('which hg > /dev/null')
      abort 'mercurial is required to install.'
    end
    return true
  end

  def check_tag
    if get_version.nil?
      abort 'undefined vim version. please run [ vvm-rb list ].'
    end
    return true
  end

  def new_version?(version = get_version)
    abort "#{version} is already installed." if version_include?(version)
    return true
  end

  def version_exist?(version = get_version)
    abort "#{version} is not installed." unless version_include?(version)
    return true
  end

  private

  def get_version
    version_regex = /^v7-.+$|^(\d\.\d(a|b){0,1}(\.\d+){0,1})$/
    regex = /(^start$|^tip$|^system$|^latest$|#{version_regex})/
    version = $*.find { |v| v =~ regex }
    return Version.format(version)
  end

  def version_include?(version)
    return Version.versions.include?(version) || use_system?(version)
  end

  def use_system?(version)
    return version == 'system' && $*.include?('use')
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
vvm-rb-0.1.6 lib/vvm-rb/validator.rb
vvm-rb-0.1.5 lib/vvm-rb/validator.rb
vvm-rb-0.1.4 lib/vvm-rb/validator.rb
vvm-rb-0.1.3 lib/vvm-rb/validator.rb
vvm-rb-0.1.2 lib/vvm-rb/validator.rb
vvm-rb-0.1.1 lib/vvm-rb/validator.rb
vvm-rb-0.1.0 lib/vvm-rb/validator.rb