class SemanticPuppet::VersionRange::AbstractRange
@api private
Public Instance Methods
# File lib/semantic_puppet/version_range.rb, line 387 def ==(other) eql?(other) end
# File lib/semantic_puppet/version_range.rb, line 367 def begin Version::MIN end
# File lib/semantic_puppet/version_range.rb, line 371 def end Version::MAX end
# File lib/semantic_puppet/version_range.rb, line 383 def eql?(other) other.class.eql?(self.class) end
# File lib/semantic_puppet/version_range.rb, line 375 def exclude_begin? false end
# File lib/semantic_puppet/version_range.rb, line 379 def exclude_end? false end
# File lib/semantic_puppet/version_range.rb, line 363 def include?(_) true end
Merge two ranges so that the result matches the intersection of all matching versions.
@param range [AbastractRange] the range to intersect with @return [AbastractRange,nil] the intersection between the ranges
@api private
# File lib/semantic_puppet/version_range.rb, line 405 def intersection(range) cmp = self.begin <=> range.end if cmp > 0 nil elsif cmp == 0 exclude_begin? || range.exclude_end? ? nil : EqRange.new(self.begin) else cmp = range.begin <=> self.end if cmp > 0 nil elsif cmp == 0 range.exclude_begin? || exclude_end? ? nil : EqRange.new(range.begin) else cmp = self.begin <=> range.begin min = if cmp < 0 range elsif cmp > 0 self else self.exclude_begin? ? self : range end cmp = self.end <=> range.end max = if cmp > 0 range elsif cmp < 0 self else self.exclude_end? ? self : range end if !max.upper_bound? min elsif !min.lower_bound? max else MinMaxRange.new(min, max) end end end end
# File lib/semantic_puppet/version_range.rb, line 391 def lower_bound? false end
Merge two ranges so that the result matches the sum of all matching versions. A merge is only possible when the ranges are either adjacent or have an overlap.
@param other [AbastractRange] the range to merge with @return [AbastractRange,nil] the result of the merge
@api private
# File lib/semantic_puppet/version_range.rb, line 454 def merge(other) if include?(other.begin) || other.include?(self.begin) cmp = self.begin <=> other.begin if cmp < 0 min = self.begin excl_begin = exclude_begin? elsif cmp > 0 min = other.begin excl_begin = other.exclude_begin? else min = self.begin excl_begin = exclude_begin? && other.exclude_begin? end cmp = self.end <=> other.end if cmp > 0 max = self.end excl_end = self.exclude_end? elsif cmp < 0 max = other.end excl_end = other.exclude_end? else max = self.end excl_end = exclude_end && other.exclude_end? end MinMaxRange.create(excl_begin ? GtRange.new(min) : GtEqRange.new(min), excl_end ? LtRange.new(max) : LtEqRange.new(max)) elsif exclude_end? && !other.exclude_begin? && self.end == other.begin # Adjacent, self before other from_to(self, other) elsif other.exclude_end? && !exclude_begin? && other.end == self.begin # Adjacent, other before self from_to(other, self) elsif !exclude_end? && !other.exclude_begin? && self.end.next(:patch) == other.begin # Adjacent, self before other from_to(self, other) elsif !other.exclude_end? && !exclude_begin? && other.end.next(:patch) == self.begin # Adjacent, other before self from_to(other, self) else # No overlap nil end end
Checks if this matcher accepts a prerelease with the same major, minor, patch triple as the given version. Only matchers where this has been explicitly stated will respond `true` to this method
@return [Boolean] `true` if this matcher accepts a prerelase with the tuple from the given version
# File lib/semantic_puppet/version_range.rb, line 503 def test_prerelease?(_) false end
# File lib/semantic_puppet/version_range.rb, line 395 def upper_bound? false end
Private Instance Methods
# File lib/semantic_puppet/version_range.rb, line 509 def from_to(a, b) MinMaxRange.create(a.exclude_begin? ? GtRange.new(a.begin) : GtEqRange.new(a.begin), b.exclude_end? ? LtRange.new(b.end) : LtEqRange.new(b.end)) end