Module: Philiprehberger::Semver::Range
- Defined in:
- lib/philiprehberger/semver/range.rb
Overview
Evaluates version constraint strings against a Version.
Supports comma-separated constraints using the operators >=, <=, >, <, =, ~> (pessimistic) and ^ (compatible). A bare version string (no operator) is treated as exact match.
Constant Summary collapse
- OPERATOR_PREFIX_REGEX =
/\A\s*[!~=<>^]/- CONSTRAINT_REGEX =
/\A\s*(>=|<=|>|<|=|~>|\^)\s*(.+)\z/- COMPARISON_OPS =
{ '>=' => :>=, '<=' => :<=, '>' => :>, '<' => :<, '=' => :== }.freeze
Class Method Summary collapse
-
.satisfies?(version, constraint) ⇒ Boolean
Check whether
versionsatisfies every comma-separatedconstraint.
Class Method Details
.satisfies?(version, constraint) ⇒ Boolean
Check whether version satisfies every comma-separated constraint.
20 21 22 23 24 25 26 27 |
# File 'lib/philiprehberger/semver/range.rb', line 20 def self.satisfies?(version, constraint) ver = version.is_a?(Version) ? version : Parser.parse(version) raise Error, 'Constraint cannot be empty' if constraint.nil? || constraint.strip.empty? constraint.split(',').all? do |part| check_constraint(ver, part.strip) end end |