[rubygems/rubygems] Use the standard RUBY_ENGINE_VERSION instead of JRUBY_VERSION
* RUBY_ENGINE and RUBY_ENGINE_VERSION are defined on every modern Ruby. * There is no such constant as TRUFFLERUBY_VERSION or RBX_VERSION. https://github.com/rubygems/rubygems/commit/431d0aefdd
This commit is contained in:
parent
2ea2108a9f
commit
86ac51c301
@ -1395,7 +1395,6 @@ begin
|
|||||||
rescue LoadError
|
rescue LoadError
|
||||||
end
|
end
|
||||||
|
|
||||||
if defined?(RUBY_ENGINE)
|
|
||||||
begin
|
begin
|
||||||
##
|
##
|
||||||
# Defaults the Ruby implementation wants to provide for RubyGems
|
# Defaults the Ruby implementation wants to provide for RubyGems
|
||||||
@ -1403,7 +1402,6 @@ if defined?(RUBY_ENGINE)
|
|||||||
require "rubygems/defaults/#{RUBY_ENGINE}"
|
require "rubygems/defaults/#{RUBY_ENGINE}"
|
||||||
rescue LoadError
|
rescue LoadError
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
##
|
##
|
||||||
# Loads the default specs.
|
# Loads the default specs.
|
||||||
|
@ -129,15 +129,8 @@ module Gem
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
##
|
|
||||||
# A wrapper around RUBY_ENGINE const that may not be defined
|
|
||||||
|
|
||||||
def self.ruby_engine
|
def self.ruby_engine
|
||||||
if defined? RUBY_ENGINE
|
|
||||||
RUBY_ENGINE
|
RUBY_ENGINE
|
||||||
else
|
|
||||||
'ruby'
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
##
|
##
|
||||||
|
@ -285,7 +285,7 @@ class Gem::Request
|
|||||||
end
|
end
|
||||||
ua << ")"
|
ua << ")"
|
||||||
|
|
||||||
ua << " #{RUBY_ENGINE}" if defined?(RUBY_ENGINE) and RUBY_ENGINE != 'ruby'
|
ua << " #{RUBY_ENGINE}" if RUBY_ENGINE != 'ruby'
|
||||||
|
|
||||||
ua
|
ua
|
||||||
end
|
end
|
||||||
|
@ -782,7 +782,7 @@ Gem dependencies file #{@path} includes git reference for both ref/branch and ta
|
|||||||
# You may also provide +engine:+ and +engine_version:+ options to restrict
|
# You may also provide +engine:+ and +engine_version:+ options to restrict
|
||||||
# this gem dependencies file to a particular ruby engine and its engine
|
# this gem dependencies file to a particular ruby engine and its engine
|
||||||
# version. This matching is performed by using the RUBY_ENGINE and
|
# version. This matching is performed by using the RUBY_ENGINE and
|
||||||
# engine_specific VERSION constants. (For JRuby, JRUBY_VERSION).
|
# RUBY_ENGINE_VERSION constants.
|
||||||
|
|
||||||
def ruby(version, options = {})
|
def ruby(version, options = {})
|
||||||
engine = options[:engine]
|
engine = options[:engine]
|
||||||
@ -809,11 +809,9 @@ Gem dependencies file #{@path} includes git reference for both ref/branch and ta
|
|||||||
end
|
end
|
||||||
|
|
||||||
if engine_version
|
if engine_version
|
||||||
my_engine_version = Object.const_get "#{Gem.ruby_engine.upcase}_VERSION"
|
if engine_version != RUBY_ENGINE_VERSION
|
||||||
|
|
||||||
if engine_version != my_engine_version
|
|
||||||
message =
|
message =
|
||||||
"Your Ruby engine version is #{Gem.ruby_engine} #{my_engine_version}, " +
|
"Your Ruby engine version is #{Gem.ruby_engine} #{RUBY_ENGINE_VERSION}, " +
|
||||||
"but your #{gem_deps_file} requires #{engine} #{engine_version}"
|
"but your #{gem_deps_file} requires #{engine} #{engine_version}"
|
||||||
|
|
||||||
raise Gem::RubyVersionMismatch, message
|
raise Gem::RubyVersionMismatch, message
|
||||||
|
@ -261,7 +261,7 @@ class TestGemRequest < Gem::TestCase
|
|||||||
def test_user_agent_engine
|
def test_user_agent_engine
|
||||||
util_save_version
|
util_save_version
|
||||||
|
|
||||||
Object.send :remove_const, :RUBY_ENGINE if defined?(RUBY_ENGINE)
|
Object.send :remove_const, :RUBY_ENGINE
|
||||||
Object.send :const_set, :RUBY_ENGINE, 'vroom'
|
Object.send :const_set, :RUBY_ENGINE, 'vroom'
|
||||||
|
|
||||||
ua = make_request(@uri, nil, nil, nil).user_agent
|
ua = make_request(@uri, nil, nil, nil).user_agent
|
||||||
@ -274,7 +274,7 @@ class TestGemRequest < Gem::TestCase
|
|||||||
def test_user_agent_engine_ruby
|
def test_user_agent_engine_ruby
|
||||||
util_save_version
|
util_save_version
|
||||||
|
|
||||||
Object.send :remove_const, :RUBY_ENGINE if defined?(RUBY_ENGINE)
|
Object.send :remove_const, :RUBY_ENGINE
|
||||||
Object.send :const_set, :RUBY_ENGINE, 'ruby'
|
Object.send :const_set, :RUBY_ENGINE, 'ruby'
|
||||||
|
|
||||||
ua = make_request(@uri, nil, nil, nil).user_agent
|
ua = make_request(@uri, nil, nil, nil).user_agent
|
||||||
@ -460,7 +460,7 @@ ERROR: Certificate is an invalid CA certificate
|
|||||||
end
|
end
|
||||||
|
|
||||||
def util_restore_version
|
def util_restore_version
|
||||||
Object.send :remove_const, :RUBY_ENGINE if defined?(RUBY_ENGINE)
|
Object.send :remove_const, :RUBY_ENGINE
|
||||||
Object.send :const_set, :RUBY_ENGINE, @orig_RUBY_ENGINE if
|
Object.send :const_set, :RUBY_ENGINE, @orig_RUBY_ENGINE if
|
||||||
defined?(@orig_RUBY_ENGINE)
|
defined?(@orig_RUBY_ENGINE)
|
||||||
|
|
||||||
@ -473,7 +473,7 @@ ERROR: Certificate is an invalid CA certificate
|
|||||||
end
|
end
|
||||||
|
|
||||||
def util_save_version
|
def util_save_version
|
||||||
@orig_RUBY_ENGINE = RUBY_ENGINE if defined? RUBY_ENGINE
|
@orig_RUBY_ENGINE = RUBY_ENGINE
|
||||||
@orig_RUBY_PATCHLEVEL = RUBY_PATCHLEVEL
|
@orig_RUBY_PATCHLEVEL = RUBY_PATCHLEVEL
|
||||||
@orig_RUBY_REVISION = RUBY_REVISION if defined? RUBY_REVISION
|
@orig_RUBY_REVISION = RUBY_REVISION if defined? RUBY_REVISION
|
||||||
end
|
end
|
||||||
|
@ -20,17 +20,14 @@ class TestGemRequestSetGemDependencyAPI < Gem::TestCase
|
|||||||
end
|
end
|
||||||
|
|
||||||
def with_engine_version(name, version)
|
def with_engine_version(name, version)
|
||||||
engine = RUBY_ENGINE if Object.const_defined? :RUBY_ENGINE
|
engine = RUBY_ENGINE
|
||||||
engine_version_const = "#{Gem.ruby_engine.upcase}_VERSION"
|
engine_version = RUBY_ENGINE_VERSION
|
||||||
engine_version = Object.const_get engine_version_const
|
|
||||||
|
|
||||||
Object.send :remove_const, :RUBY_ENGINE if engine
|
Object.send :remove_const, :RUBY_ENGINE
|
||||||
Object.send :remove_const, engine_version_const if name == 'ruby' and
|
Object.send :remove_const, :RUBY_ENGINE_VERSION
|
||||||
Object.const_defined? engine_version_const
|
|
||||||
|
|
||||||
new_engine_version_const = "#{name.upcase}_VERSION"
|
|
||||||
Object.const_set :RUBY_ENGINE, name if name
|
Object.const_set :RUBY_ENGINE, name if name
|
||||||
Object.const_set new_engine_version_const, version if version
|
Object.const_set :RUBY_ENGINE_VERSION, version if version
|
||||||
|
|
||||||
Gem.instance_variable_set :@ruby_version, Gem::Version.new(version)
|
Gem.instance_variable_set :@ruby_version, Gem::Version.new(version)
|
||||||
|
|
||||||
@ -38,17 +35,12 @@ class TestGemRequestSetGemDependencyAPI < Gem::TestCase
|
|||||||
yield
|
yield
|
||||||
ensure
|
ensure
|
||||||
Object.send :remove_const, :RUBY_ENGINE if name
|
Object.send :remove_const, :RUBY_ENGINE if name
|
||||||
Object.send :remove_const, new_engine_version_const if version
|
Object.send :remove_const, :RUBY_ENGINE_VERSION if version
|
||||||
|
|
||||||
Object.send :remove_const, engine_version_const if name == 'ruby' and
|
Object.const_set :RUBY_ENGINE, engine
|
||||||
Object.const_defined? engine_version_const
|
Object.const_set :RUBY_ENGINE_VERSION, engine_version
|
||||||
|
|
||||||
Object.const_set :RUBY_ENGINE, engine if engine
|
Gem.send :remove_instance_variable, :@ruby_version
|
||||||
Object.const_set engine_version_const, engine_version unless
|
|
||||||
Object.const_defined? engine_version_const
|
|
||||||
|
|
||||||
Gem.send :remove_instance_variable, :@ruby_version if
|
|
||||||
Gem.instance_variables.include? :@ruby_version
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -839,22 +831,19 @@ end
|
|||||||
def test_with_engine_version
|
def test_with_engine_version
|
||||||
version = RUBY_VERSION
|
version = RUBY_VERSION
|
||||||
engine = Gem.ruby_engine
|
engine = Gem.ruby_engine
|
||||||
|
engine_version = RUBY_ENGINE_VERSION
|
||||||
engine_version_const = "#{Gem.ruby_engine.upcase}_VERSION"
|
|
||||||
engine_version = Object.const_get engine_version_const
|
|
||||||
|
|
||||||
with_engine_version 'other', '1.2.3' do
|
with_engine_version 'other', '1.2.3' do
|
||||||
assert_equal 'other', Gem.ruby_engine
|
assert_equal 'other', Gem.ruby_engine
|
||||||
assert_equal '1.2.3', OTHER_VERSION
|
assert_equal '1.2.3', RUBY_ENGINE_VERSION
|
||||||
|
|
||||||
assert_equal version, RUBY_VERSION if engine
|
assert_equal version, RUBY_VERSION
|
||||||
end
|
end
|
||||||
|
|
||||||
assert_equal version, RUBY_VERSION
|
assert_equal version, RUBY_VERSION
|
||||||
assert_equal engine, Gem.ruby_engine
|
assert_equal engine, Gem.ruby_engine
|
||||||
|
|
||||||
assert_equal engine_version, Object.const_get(engine_version_const) if
|
assert_equal engine_version, RUBY_ENGINE_VERSION if engine
|
||||||
engine
|
|
||||||
end
|
end
|
||||||
|
|
||||||
end unless Gem.java_platform?
|
end unless Gem.java_platform?
|
||||||
|
Loading…
x
Reference in New Issue
Block a user