Skip to content

Commit

Permalink
Introduce default prerelease requirement
Browse files Browse the repository at this point in the history
  • Loading branch information
deivid-rodriguez committed Sep 24, 2019
1 parent b3b5c2d commit 506c5bc
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 3 deletions.
2 changes: 1 addition & 1 deletion lib/rubygems/core_ext/kernel_require.rb
Expand Up @@ -66,7 +66,7 @@ def require(path)

if spec = Gem.find_unresolved_default_spec(path)
begin
Kernel.send(:gem, spec.name, "#{Gem::Requirement.default}.a")
Kernel.send(:gem, spec.name, Gem::Requirement.default_prerelease)
rescue Exception
RUBYGEMS_ACTIVATION_MONITOR.exit
raise
Expand Down
2 changes: 1 addition & 1 deletion lib/rubygems/installer.rb
Expand Up @@ -776,7 +776,7 @@ def app_script_text(bin_file_name)
require 'rubygems'
version = "#{Gem::Requirement.default}.a"
version = "#{Gem::Requirement.default_prerelease}"
str = ARGV.first
if str
Expand Down
13 changes: 12 additions & 1 deletion lib/rubygems/requirement.rb
Expand Up @@ -32,10 +32,15 @@ class Gem::Requirement
PATTERN = /\A#{PATTERN_RAW}\z/.freeze

##
# The default requirement matches any version
# The default requirement matches any non-prerelease version

DefaultRequirement = [">=", Gem::Version.new(0)].freeze

##
# The default requirement matches any version

DefaultPrereleaseRequirement = [">=", Gem::Version.new("0.a")].freeze

##
# Raised when a bad requirement is encountered

Expand Down Expand Up @@ -73,6 +78,10 @@ def self.default
new '>= 0'
end

def self.default_prerelease
new '>= 0.a'
end

###
# A source set requirement, used for Gemfiles and lockfiles

Expand Down Expand Up @@ -101,6 +110,8 @@ def self.parse(obj)

if $1 == ">=" && $2 == "0"
DefaultRequirement
elsif $1 == ">=" && $2 == "0.a"
DefaultPrereleaseRequirement
else
[$1 || "=", Gem::Version.new($2)]
end
Expand Down

0 comments on commit 506c5bc

Please sign in to comment.