From 6e46b9b8b3657822306a365d6538e20fcf764d9b Mon Sep 17 00:00:00 2001 From: Luiz Eduardo Kowalski Date: Mon, 23 Dec 2024 11:50:46 -0300 Subject: [PATCH] [rubygems/rubygems] Add support for mise.toml file https://github.com/rubygems/rubygems/commit/809a2a17a7 --- lib/bundler/ruby_dsl.rb | 6 +++--- spec/bundler/bundler/ruby_dsl_spec.rb | 13 +++++++++++++ 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/lib/bundler/ruby_dsl.rb b/lib/bundler/ruby_dsl.rb index fb4b79c4df..1fc4981d29 100644 --- a/lib/bundler/ruby_dsl.rb +++ b/lib/bundler/ruby_dsl.rb @@ -42,9 +42,9 @@ module Bundler # Loads the file relative to the dirname of the Gemfile itself. def normalize_ruby_file(filename) file_content = Bundler.read_file(gemfile.dirname.join(filename)) - # match "ruby-3.2.2" or "ruby 3.2.2" capturing version string up to the first space or comment - if /^ruby(-|\s+)([^\s#]+)/.match(file_content) - $2 + # match "ruby-3.2.2", ruby = "3.2.2" or "ruby 3.2.2" capturing version string up to the first space or comment + if /^ruby[\s-]*(?:=\s*)?"?([^\s#"]+)"?/.match(file_content) + $1 else file_content.strip end diff --git a/spec/bundler/bundler/ruby_dsl_spec.rb b/spec/bundler/bundler/ruby_dsl_spec.rb index c5ebbdf4db..2607f746e7 100644 --- a/spec/bundler/bundler/ruby_dsl_spec.rb +++ b/spec/bundler/bundler/ruby_dsl_spec.rb @@ -172,6 +172,19 @@ RSpec.describe Bundler::RubyDsl do end end + context "with a mise.toml file format" do + let(:file) { "mise.toml" } + let(:ruby_version_arg) { nil } + let(:file_content) do + <<~TOML + [tools] + ruby = "#{version}" + TOML + end + + it_behaves_like "it stores the ruby version" + end + context "with a .tool-versions file format" do let(:file) { ".tool-versions" } let(:ruby_version_arg) { nil }