Class: Gitlab::QA::Support::GitlabVersionInfo
- Inherits:
-
Object
- Object
- Gitlab::QA::Support::GitlabVersionInfo
- Defined in:
- lib/gitlab/qa/support/gitlab_version_info.rb
Constant Summary collapse
- VERSION_PATTERN =
/^(?<version>\d+\.\d+\.\d+)/
- COMPONENT_PATTERN =
/^(?<major>\d+)\.(?<minor>\d+)\.(?<patch>\d+)/
- VersionNotFoundError =
Class.new(RuntimeError)
Instance Method Summary collapse
-
#initialize(current_version, edition) ⇒ GitlabVersionInfo
constructor
Get previous gitlab version.
-
#latest_patch(version) ⇒ String
Get latest patch for specific version number.
-
#previous_version(semver_component) ⇒ Gem::Version
Get N - 1 version number.
Constructor Details
#initialize(current_version, edition) ⇒ GitlabVersionInfo
Get previous gitlab version
16 17 18 19 20 |
# File 'lib/gitlab/qa/support/gitlab_version_info.rb', line 16 def initialize(current_version, edition) @current_version = current_version @edition = edition @logger = Runtime::Logger.logger end |
Instance Method Details
#latest_patch(version) ⇒ String
Get latest patch for specific version number
latest_patch(Gem::Version.new(“14.10”)) => “14.10.5” latest_patch(Gem::Version.new(“14.10.5”)) => “14.10.5”
47 48 49 50 51 52 53 54 |
# File 'lib/gitlab/qa/support/gitlab_version_info.rb', line 47 def latest_patch(version) # check if version is already a patch version return version if version.to_s.split('.').size == 3 versions.find { |ver| ver.to_s.match?(/^#{version}\./) }.tap do |ver| raise_version_not_found("Latest patch version for version #{version}") unless ver end end |
#previous_version(semver_component) ⇒ Gem::Version
Get N - 1 version number
26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/gitlab/qa/support/gitlab_version_info.rb', line 26 def previous_version(semver_component) case semver_component when "major" previous_major when "minor" previous_minor when "patch" previous_patch else raise("Unsupported semver component, must be major|minor|patch") end end |