Module: Kompo::KompoVfsVersionCheck

Defined in:
lib/kompo/tasks/kompo_vfs_version_check.rb

Overview

Verifies that the installed kompo-vfs version meets minimum requirements. Checks the KOMPO_VFS_VERSION file in the library directory.

Defined Under Namespace

Classes: IncompatibleVersionError

Constant Summary collapse

VERSION_FILE =
"KOMPO_VFS_VERSION"

Class Method Summary collapse

Class Method Details

.build_error_message(actual_version, required_version) ⇒ Object



34
35
36
37
38
39
40
41
42
43
44
# File 'lib/kompo/tasks/kompo_vfs_version_check.rb', line 34

def self.build_error_message(actual_version, required_version)
  "    kompo-vfs version \#{actual_version} is too old.\n    Required: >= \#{required_version}\n\n    Please upgrade:\n      Homebrew: brew update && brew upgrade kompo-vfs\n        (If upgrade fails, try: brew tap --force-auto-update ahogappa/kompo)\n      Source: cd ~/.kompo/kompo-vfs && git pull && cargo build --release\n  MSG\nend\n".chomp

.build_missing_file_message(version_file) ⇒ Object



46
47
48
49
50
51
52
53
54
55
56
# File 'lib/kompo/tasks/kompo_vfs_version_check.rb', line 46

def self.build_missing_file_message(version_file)
  "    kompo-vfs version file not found at: \#{version_file}\n    Your kompo-vfs installation may be outdated (< 0.5.0).\n\n    Please upgrade:\n      Homebrew: brew update && brew upgrade kompo-vfs\n        (If upgrade fails, try: brew tap --force-auto-update ahogappa/kompo)\n      Source: cd ~/.kompo/kompo-vfs && git pull && cargo build --release\n  MSG\nend\n".chomp

.get_version(lib_path) ⇒ Object



22
23
24
25
26
27
28
# File 'lib/kompo/tasks/kompo_vfs_version_check.rb', line 22

def self.get_version(lib_path)
  version_file = File.join(lib_path, VERSION_FILE)

  raise IncompatibleVersionError, build_missing_file_message(version_file) unless File.exist?(version_file)

  File.read(version_file).strip
end

.verify!(lib_path) ⇒ Object



13
14
15
16
17
18
19
20
# File 'lib/kompo/tasks/kompo_vfs_version_check.rb', line 13

def self.verify!(lib_path)
  actual_version = get_version(lib_path)
  required_version = Kompo::KOMPO_VFS_MIN_VERSION

  return if version_satisfies?(actual_version, required_version)

  raise IncompatibleVersionError, build_error_message(actual_version, required_version)
end

.version_satisfies?(actual, required) ⇒ Boolean

Returns:

  • (Boolean)


30
31
32
# File 'lib/kompo/tasks/kompo_vfs_version_check.rb', line 30

def self.version_satisfies?(actual, required)
  Gem::Version.new(actual) >= Gem::Version.new(required)
end