class Capsium::Package::VersionRange
A semver range for metadata.dependencies (ARCHITECTURE.md section 4a), covering the standardβs examples: β*β, exact versions, wildcards and partials (β1.xβ, β1.2.xβ, β1.2β), caret (β^1.2.3β), tilde (β~1.2.3β), comparison operators (>=, <=, >, <, =) and conjunctions joined by comma and/or space (β>=1.0.0, <2.0.0β).
Constants
- NUMERIC_PART
- WILDCARD_PART
Public Class Methods
(Array[[ String, Version ]] bounds) → void
Source
# File lib/capsium/package/version.rb, line 182 def initialize(bounds) @bounds = bounds end
(String string) → VersionRange
Source
# File lib/capsium/package/version.rb, line 88 def self.parse(string) terms = string.to_s.strip.split(/[,\s]+/).reject(&:empty?) return new([[">=", Version.new(0, 0, 0)]]) if terms.empty? || terms == ["*"] new(terms.flat_map { |term| expand_term(term) }) end
Public Instance Methods
(String | Version version) → bool
Source
# File lib/capsium/package/version.rb, line 186 def satisfied_by?(version) version = Version.parse(version) unless version.is_a?(Version) @bounds.all? { |operator, bound| holds?(operator, version <=> bound) } end