Class: ReleaseVersion

Inherits:
String
  • Object
show all
Defined in:
lib/gitlab_releases/release_version.rb

Constant Summary collapse

VERSION_REGEX =
/
\A(?<major>\d+)
\.(?<minor>\d+)
(\.(?<patch>\d+))?
  (-(?<rc>rc(?<rc_number>\d*)))?
  (-\h+\.\h+)?
  (-ee|\.ee\.\d+)?\z
/x

Instance Method Summary collapse

Instance Method Details

#ee?Boolean

Returns:

  • (Boolean)


55
56
57
# File 'lib/gitlab_releases/release_version.rb', line 55

def ee?
  end_with?('-ee')
end

#majorObject



13
14
15
# File 'lib/gitlab_releases/release_version.rb', line 13

def major
  @major ||= extract_from_version(:major).to_i
end

#minorObject



17
18
19
# File 'lib/gitlab_releases/release_version.rb', line 17

def minor
  @minor ||= extract_from_version(:minor).to_i
end

#next_majorObject



29
30
31
# File 'lib/gitlab_releases/release_version.rb', line 29

def next_major
  "#{major + 1}.0"
end

#next_minorObject



25
26
27
# File 'lib/gitlab_releases/release_version.rb', line 25

def next_minor
  "#{major}.#{minor + 1}"
end

#next_patchObject



49
50
51
52
53
# File 'lib/gitlab_releases/release_version.rb', line 49

def next_patch
  new_patch = self.class.new("#{major}.#{minor}.#{patch + 1}")

  ee? ? new_patch.to_ee : new_patch
end

#patchObject



21
22
23
# File 'lib/gitlab_releases/release_version.rb', line 21

def patch
  @patch ||= extract_from_version(:patch).to_i
end

#patch?Boolean

Returns:

  • (Boolean)


59
60
61
# File 'lib/gitlab_releases/release_version.rb', line 59

def patch?
  patch.positive?
end

#previous_minorObject



37
38
39
# File 'lib/gitlab_releases/release_version.rb', line 37

def previous_minor
  "#{major}.#{minor - 1}"
end

#previous_patchObject



41
42
43
44
45
46
47
# File 'lib/gitlab_releases/release_version.rb', line 41

def previous_patch
  return unless patch?

  new_patch = self.class.new("#{major}.#{minor}.#{patch - 1}")

  ee? ? new_patch.to_ee : new_patch
end

#to_eeObject



63
64
65
66
67
# File 'lib/gitlab_releases/release_version.rb', line 63

def to_ee
  return self if ee?

  self.class.new("#{self}-ee")
end

#to_minorObject



33
34
35
# File 'lib/gitlab_releases/release_version.rb', line 33

def to_minor
  "#{major}.#{minor}"
end