Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 26 additions & 2 deletions bundler/lib/bundler/current_ruby.rb
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,18 @@ def jruby?
end

def maglev?
message =
"`CurrentRuby#maglev?` is deprecated with no replacement. Please use the " \
"built-in Ruby `RUBY_ENGINE` constant to check the Ruby implementation you are running on."
removed_message =
"`CurrentRuby#maglev?` was removed with no replacement. Please use the " \
"built-in Ruby `RUBY_ENGINE` constant to check the Ruby implementation you are running on."
internally_exempted = caller_locations(1, 1).first.path == __FILE__

unless internally_exempted
SharedHelpers.major_deprecation(2, message, removed_message: removed_message, print_caller_location: true)
end

RUBY_ENGINE == "maglev"
end

Expand All @@ -71,12 +83,24 @@ def windows?
RUBY_VERSION.start_with?("#{version}.")
end

all_platforms = PLATFORM_MAP.keys << "maglev"
all_platforms.each do |platform|
PLATFORM_MAP.keys.each do |platform|
define_method(:"#{platform}_#{trimmed_version}?") do
send(:"#{platform}?") && send(:"on_#{trimmed_version}?")
end
end

define_method(:"maglev_#{trimmed_version}?") do
message =
"`CurrentRuby##{__method__}` is deprecated with no replacement. Please use the " \
"built-in Ruby `RUBY_ENGINE` and `RUBY_VERSION` constants to perform a similar check."
removed_message =
"`CurrentRuby##{__method__}` was removed with no replacement. Please use the " \
"built-in Ruby `RUBY_ENGINE` and `RUBY_VERSION` constants to perform a similar check."

SharedHelpers.major_deprecation(2, message, removed_message: removed_message, print_caller_location: true)

send(:"maglev?") && send(:"on_#{trimmed_version}?")
end
end
end
end
16 changes: 16 additions & 0 deletions bundler/spec/bundler/current_ruby_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -137,4 +137,20 @@
expect(subject).to eq(platforms.merge(deprecated))
end
end

describe "Deprecated platform" do
it "Outputs a deprecation warning when calling maglev?", bundler: "< 3" do
expect(Bundler.ui).to receive(:warn).with(/`CurrentRuby#maglev\?` is deprecated with no replacement./)

Bundler.current_ruby.maglev?
end

it "Outputs a deprecation warning when calling maglev_31?", bundler: "< 3" do
expect(Bundler.ui).to receive(:warn).with(/`CurrentRuby#maglev_31\?` is deprecated with no replacement./)

Bundler.current_ruby.maglev_31?
end

pending "is removed and shows a helpful error message about it", bundler: "3"
end
end
Loading