summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/rubygems.rb12
-rw-r--r--lib/rubygems/defaults.rb9
-rw-r--r--lib/rubygems/request.rb2
-rw-r--r--lib/rubygems/request_set/gem_dependency_api.rb8
-rw-r--r--test/rubygems/test_gem_request.rb8
-rw-r--r--test/rubygems/test_gem_request_set_gem_dependency_api.rb43
6 files changed, 30 insertions, 52 deletions
diff --git a/lib/rubygems.rb b/lib/rubygems.rb
index 64c21e1..84c1c74 100644
--- a/lib/rubygems.rb
+++ b/lib/rubygems.rb
@@ -1395,14 +1395,12 @@ begin
rescue LoadError
end
-if defined?(RUBY_ENGINE)
- begin
- ##
- # Defaults the Ruby implementation wants to provide for RubyGems
+begin
+ ##
+ # Defaults the Ruby implementation wants to provide for RubyGems
- require "rubygems/defaults/#{RUBY_ENGINE}"
- rescue LoadError
- end
+ require "rubygems/defaults/#{RUBY_ENGINE}"
+rescue LoadError
end
##
diff --git a/lib/rubygems/defaults.rb b/lib/rubygems/defaults.rb
index da304b2..cdc5fb7 100644
--- a/lib/rubygems/defaults.rb
+++ b/lib/rubygems/defaults.rb
@@ -129,15 +129,8 @@ module Gem
end
end
- ##
- # A wrapper around RUBY_ENGINE const that may not be defined
-
def self.ruby_engine
- if defined? RUBY_ENGINE
- RUBY_ENGINE
- else
- 'ruby'
- end
+ RUBY_ENGINE
end
##
diff --git a/lib/rubygems/request.rb b/lib/rubygems/request.rb
index 1ed2b8a..435c7c5 100644
--- a/lib/rubygems/request.rb
+++ b/lib/rubygems/request.rb
@@ -285,7 +285,7 @@ class Gem::Request
end
ua << ")"
- ua << " #{RUBY_ENGINE}" if defined?(RUBY_ENGINE) and RUBY_ENGINE != 'ruby'
+ ua << " #{RUBY_ENGINE}" if RUBY_ENGINE != 'ruby'
ua
end
diff --git a/lib/rubygems/request_set/gem_dependency_api.rb b/lib/rubygems/request_set/gem_dependency_api.rb
index a4d803f..cb36a62 100644
--- a/lib/rubygems/request_set/gem_dependency_api.rb
+++ b/lib/rubygems/request_set/gem_dependency_api.rb
@@ -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
# this gem dependencies file to a particular ruby engine and its engine
# 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 = {})
engine = options[:engine]
@@ -809,11 +809,9 @@ Gem dependencies file #{@path} includes git reference for both ref/branch and ta
end
if engine_version
- my_engine_version = Object.const_get "#{Gem.ruby_engine.upcase}_VERSION"
-
- if engine_version != my_engine_version
+ if engine_version != RUBY_ENGINE_VERSION
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}"
raise Gem::RubyVersionMismatch, message
diff --git a/test/rubygems/test_gem_request.rb b/test/rubygems/test_gem_request.rb
index b9601b7..2a756ea 100644
--- a/test/rubygems/test_gem_request.rb
+++ b/test/rubygems/test_gem_request.rb
@@ -261,7 +261,7 @@ class TestGemRequest < Gem::TestCase
def test_user_agent_engine
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'
ua = make_request(@uri, nil, nil, nil).user_agent
@@ -274,7 +274,7 @@ class TestGemRequest < Gem::TestCase
def test_user_agent_engine_ruby
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'
ua = make_request(@uri, nil, nil, nil).user_agent
@@ -460,7 +460,7 @@ ERROR: Certificate is an invalid CA certificate
end
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
defined?(@orig_RUBY_ENGINE)
@@ -473,7 +473,7 @@ ERROR: Certificate is an invalid CA certificate
end
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_REVISION = RUBY_REVISION if defined? RUBY_REVISION
end
diff --git a/test/rubygems/test_gem_request_set_gem_dependency_api.rb b/test/rubygems/test_gem_request_set_gem_dependency_api.rb
index 959c285..f3d4c6f 100644
--- a/test/rubygems/test_gem_request_set_gem_dependency_api.rb
+++ b/test/rubygems/test_gem_request_set_gem_dependency_api.rb
@@ -20,35 +20,27 @@ class TestGemRequestSetGemDependencyAPI < Gem::TestCase
end
def with_engine_version(name, version)
- engine = RUBY_ENGINE if Object.const_defined? :RUBY_ENGINE
- engine_version_const = "#{Gem.ruby_engine.upcase}_VERSION"
- engine_version = Object.const_get engine_version_const
+ engine = RUBY_ENGINE
+ engine_version = RUBY_ENGINE_VERSION
- Object.send :remove_const, :RUBY_ENGINE if engine
- Object.send :remove_const, engine_version_const if name == 'ruby' and
- Object.const_defined? engine_version_const
+ Object.send :remove_const, :RUBY_ENGINE
+ Object.send :remove_const, :RUBY_ENGINE_VERSION
- new_engine_version_const = "#{name.upcase}_VERSION"
- Object.const_set :RUBY_ENGINE, name if name
- Object.const_set new_engine_version_const, version if version
+ Object.const_set :RUBY_ENGINE, name if name
+ Object.const_set :RUBY_ENGINE_VERSION, version if version
Gem.instance_variable_set :@ruby_version, Gem::Version.new(version)
begin
yield
ensure
- Object.send :remove_const, :RUBY_ENGINE if name
- Object.send :remove_const, new_engine_version_const if version
+ Object.send :remove_const, :RUBY_ENGINE if name
+ Object.send :remove_const, :RUBY_ENGINE_VERSION if version
- Object.send :remove_const, engine_version_const if name == 'ruby' and
- Object.const_defined? engine_version_const
+ Object.const_set :RUBY_ENGINE, engine
+ Object.const_set :RUBY_ENGINE_VERSION, engine_version
- Object.const_set :RUBY_ENGINE, engine if engine
- 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
+ Gem.send :remove_instance_variable, :@ruby_version
end
end
@@ -838,23 +830,20 @@ end
def test_with_engine_version
version = RUBY_VERSION
- engine = Gem.ruby_engine
-
- engine_version_const = "#{Gem.ruby_engine.upcase}_VERSION"
- engine_version = Object.const_get engine_version_const
+ engine = Gem.ruby_engine
+ engine_version = RUBY_ENGINE_VERSION
with_engine_version 'other', '1.2.3' do
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
assert_equal version, RUBY_VERSION
assert_equal engine, Gem.ruby_engine
- assert_equal engine_version, Object.const_get(engine_version_const) if
- engine
+ assert_equal engine_version, RUBY_ENGINE_VERSION if engine
end
end unless Gem.java_platform?