Module: ForemanFogProxmox::Semver
- Defined in:
- lib/foreman_fog_proxmox/semver.rb
Defined Under Namespace
Classes: SemverClass
Constant Summary collapse
- SEMVER_REGEX =
/^(\d+)[.](\d+)([.](\d+))?(-([.\w]+))?$/.freeze
Class Method Summary collapse
Class Method Details
.semver?(version) ⇒ Boolean
82 83 84 |
# File 'lib/foreman_fog_proxmox/semver.rb', line 82 def self.semver?(version) version.is_a?(String) && version.match(SEMVER_REGEX) end |
.to_semver(version) ⇒ Object
86 87 88 89 90 91 92 93 94 95 96 97 |
# File 'lib/foreman_fog_proxmox/semver.rb', line 86 def self.to_semver(version) raise ArgumentError unless semver?(version) version_a = version.scan(SEMVER_REGEX) raise ArgumentError if version_a.empty? semver_a = version_a.first raise ArgumentError if semver_a.empty? raise ArgumentError unless semver_a.size == 6 SemverClass.new(semver_a[0], semver_a[1], semver_a[3], semver_a[5]) end |