class Solve::Constraint

def split(constraint)

Returns:
  • (Array, nil) -

Other tags:
    Example: splitting a string without a valid version string -
    Example: splitting a string without a constraint operator -
    Example: splitting a string with a constraint operator and valid version string -

Parameters:
  • constraint (#to_s) --
def split(constraint)
  if constraint =~ /^[0-9]/
    operator = "="
    version  = constraint
  else
    _, operator, version = REGEXP.match(constraint).to_a
  end
  if operator.nil?
    raise Errors::InvalidConstraintFormat.new(constraint)
  end
  split_version = case version.to_s
  when /^(\d+)\.(\d+)\.(\d+)(-([0-9a-z\-\.]+))?(\+([0-9a-z\-\.]+))?$/i
    [ $1.to_i, $2.to_i, $3.to_i, $5, $7 ]
  when /^(\d+)\.(\d+)\.(\d+)?$/
    [ $1.to_i, $2.to_i, $3.to_i, nil, nil ]
  when /^(\d+)\.(\d+)?$/
    [ $1.to_i, $2.to_i, nil, nil, nil ]
  when /^(\d+)$/
    [ $1.to_i, nil, nil, nil, nil ]
  else
    raise Errors::InvalidConstraintFormat.new(constraint)
  end
  [ operator, split_version ].flatten
end