Module: Homebrew::Semver Private
- Defined in:
- semver.rb
Overview
This module is part of a private API. This module may only be used in the Homebrew/brew repository. Third parties should avoid using this module if possible, as it may be removed or changed without warning.
SemVer 2.0 comparison for OSV SEMVER ranges (https://semver.org/#spec-item-11).
Kept separate from ::Version, whose ordering differs for prerelease and
build metadata. Minor/patch may be omitted; other spec violations or
inputs over 256 bytes return nil.
Class Method Summary collapse
- .compare(left, right) ⇒ Integer? private
- .prerelease?(version) ⇒ Boolean private
- .release_version(version) ⇒ String? private
Class Method Details
.compare(left, right) ⇒ Integer?
This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.
37 38 39 40 41 42 43 44 45 46 |
# File 'semver.rb', line 37 def self.compare(left, right) a = parse(left) b = parse(right) return if a.nil? || b.nil? core = a.fetch(:core) <=> b.fetch(:core) return core unless core.zero? compare_prerelease(a.fetch(:prerelease), b.fetch(:prerelease)) end |
.prerelease?(version) ⇒ Boolean
This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.
49 50 51 52 53 54 |
# File 'semver.rb', line 49 def self.prerelease?(version) parsed = parse(version) return false if parsed.nil? parsed.fetch(:prerelease).any? end |
.release_version(version) ⇒ String?
This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.
57 58 59 60 61 62 |
# File 'semver.rb', line 57 def self.release_version(version) parsed = parse(version) return if parsed.nil? || parsed.fetch(:prerelease).empty? parsed.fetch(:core).join(".") end |