Module: Antrapol::ToolRack::VersionUtils

Includes:
ConditionUtils
Defined in:
lib/toolrack/version_utils.rb

Defined Under Namespace

Classes: VersionUtilsError

Instance Method Summary collapse

Instance Method Details

#is_version_equal?(*args) ⇒ Boolean

Returns:

  • (Boolean)


11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/toolrack/version_utils.rb', line 11

def is_version_equal?(*args)
  res = true
  target = Gem::Version.new(args.first)
  args.each do |a|
    subj = Gem::Version.new(a)
    res = (subj == target)
    break if not res
    target = subj
  end

  res
end

#possible_versions(ver) ⇒ Object

Raises:



24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/toolrack/version_utils.rb', line 24

def possible_versions(ver)
  raise VersionUtilsError, "Given version to extrapolate is empty" if is_empty?(ver)
  vv = ver.to_s.split('.')
  tv = vv.clone
  res = []
  cnt = 0
  (0...vv.length).each do |i|
    tv = vv.clone
    tv[i] = tv[i].to_i+1

    j = i
    loop do
      break if j >= (vv.length-1)
      j += 1
      tv[j] = 0
    end
    res << tv.join(".")
  end
  res
end