class Bundler::RubyVersion
def initialize(versions, patchlevel, engine, engine_version)
def initialize(versions, patchlevel, engine, engine_version) # The parameters to this method must satisfy the # following constraints, which are verified in # the DSL: # # * If an engine is specified, an engine version # must also be specified # * If an engine version is specified, an engine # must also be specified # * If the engine is "ruby", the engine version # must not be specified, or the engine version # specified must match the version. @versions = Array(versions).map do |v| normalized_v = normalize_version(v) unless Gem::Requirement::PATTERN.match?(normalized_v) raise InvalidArgumentError, "#{v} is not a valid requirement on the Ruby version" end op, v = Gem::Requirement.parse(normalized_v) op == "=" ? v.to_s : "#{op} #{v}" end @gem_version = Gem::Requirement.create(@versions.first).requirements.first.last @input_engine = engine&.to_s @engine = engine&.to_s || "ruby" @engine_versions = (engine_version && Array(engine_version)) || @versions @engine_gem_version = Gem::Requirement.create(@engine_versions.first).requirements.first.last @patchlevel = patchlevel || (@gem_version.prerelease? ? "-1" : nil) end