Module: Libyui::Tasks::Helpers

Defined in:
lib/libyui/tasks.rb

Overview

Some helpers to be used on tasks definition

Instance Method Summary collapse

Instance Method Details

#cmake_value(s, key) ⇒ "3"

Extracts the value from a CMake string



55
56
57
58
59
# File 'lib/libyui/tasks.rb', line 55

def cmake_value(s, key)
  e_key = Regexp.escape(key)
  m = /SET\s*\(\s*#{e_key}\s+"([^"]*)"\s*\)/.match(s)
  m ? m[1] : nil
end

#cmake_version(file = nil) ⇒ String

Returns the CMake version from the version file. VERSION_TWEAK is optional.

See Also:



67
68
69
70
71
72
73
# File 'lib/libyui/tasks.rb', line 67

def cmake_version(file = nil)
  f = File.read(file || VERSION_CMAKE)
  [cmake_value(f, "VERSION_MAJOR"),
   cmake_value(f, "VERSION_MINOR"),
   cmake_value(f, "VERSION_PATCH"),
   cmake_value(f, "VERSION_TWEAK")].compact.join(".")
end

#spec_version(spec_filename) ⇒ String

Read the version from spec file



46
47
48
# File 'lib/libyui/tasks.rb', line 46

def spec_version(spec_filename)
  File.read(spec_filename)[/^Version:\s*(\S+)/, 1]
end