Class SemanticPuppet::VersionRange
In: lib/semantic_puppet/version_range.rb
Parent: Range

Methods

&   inspect   intersection   parse   to_s  

Constants

NOT_A_VERSION_RANGE = ArgumentError.new("value must be a #{VersionRange}")
EMPTY_RANGE = VersionRange.parse('< 0.0.0').freeze   A range that matches no versions

Public Class methods

Parses a version range string into a comparable {VersionRange} instance.

Currently parsed version range string may take any of the following: forms:

  • Regular Semantic Version strings
    • ex. `"1.0.0"`, `"1.2.3-pre"`
  • Partial Semantic Version strings
    • ex. `"1.0.x"`, `"1"`, `"2.X"`
  • Inequalities
    • ex. `"> 1.0.0"`, `"<3.2.0"`, `">=4.0.0"`
  • Approximate Versions
    • ex. `"~1.0.0"`, `"~ 3.2.0"`, `"~4.0.0"`
  • Inclusive Ranges
    • ex. `"1.0.0 - 1.3.9"`
  • Range Intersections
    • ex. `">1.0.0 <=2.3.0"`

@param range_str [String] the version range string to parse @return [VersionRange] a new {VersionRange} instance

Public Instance methods

&(other)

Alias for intersection

inspect()

Alias for to_s

Computes the intersection of a pair of ranges. If the ranges have no useful intersection, an empty range is returned.

@param other [VersionRange] the range to intersect with @return [VersionRange] the common subset

Returns a string representation of this range, prefering simple common expressions for comprehension.

@return [String] a range expression representing this VersionRange

[Validate]