class Bundler::PubGrub::VersionConstraint

def allows_all?(other)

def allows_all?(other)
  range.allows_all?(other.range)
end

def allows_any?(other)

def allows_any?(other)
  range.intersects?(other.range)
end

def any(package)

def any(package)
  new(package, range: VersionRange.any)
end

def any?

Does this match every version of the package
def any?
  range.any?
end

def constraint_string

def constraint_string
  if any?
    ">= 0"
  else
    range.to_s
  end
end

def difference(other)

def difference(other)
  intersect(other.invert)
end

def disjoint?(other)

def disjoint?(other)
  !overlap?(other)
end

def empty(package)

def empty(package)
  new(package, range: VersionRange.empty)
end

def empty?

def empty?
  range.empty?
end

def eql?(other)

def eql?(other)
  package.eql?(other.package) &&
    range.eql?(other.range)
end

def exact(package, version)

def exact(package, version)
  range = VersionRange.new(min: version, max: version, include_min: true, include_max: true)
  new(package, range: range)
end

def hash

def hash
  package.hash ^ range.hash
end

def initialize(package, range: nil)

Parameters:
  • range (Bundler::PubGrub::VersionRange) --
  • package (Bundler::PubGrub::Package) --
def initialize(package, range: nil)
  @package = package
  @range = range
end

def inspect

def inspect
  "#<#{self.class} #{self}>"
end

def intersect(other)

def intersect(other)
  unless package == other.package
    raise ArgumentError, "Can only intersect between VersionConstraint of the same package"
  end
  self.class.new(package, range: range.intersect(other.range))
end

def invert

def invert
  new_range = range.invert
  self.class.new(package, range: new_range)
end

def overlap?(other)

def overlap?(other)
  other.allows_any?(self)
end

def relation(other)

def relation(other)
  if subset?(other)
    :subset
  elsif overlap?(other)
    :overlap
  else
    :disjoint
  end
end

def subset?(other)

def subset?(other)
  other.allows_all?(self)
end

def to_s(allow_every: false)

def to_s(allow_every: false)
  if Package.root?(package)
    package.to_s
  elsif allow_every && any?
    "every version of #{package}"
  else
    "#{package} #{constraint_string}"
  end
end

def union(other)

def union(other)
  unless package == other.package
    raise ArgumentError, "Can only intersect between VersionConstraint of the same package"
  end
  self.class.new(package, range: range.union(other.range))
end