Skip to content

Commit 3b50f4b

Browse files
hituzi-no-sippomatzbot
authored andcommitted
[ruby/rubygems] Support single quotes in mise format ruby version
ruby/rubygems@a7d7ab39dd
1 parent 3b3ab33 commit 3b50f4b

File tree

2 files changed

+16
-6
lines changed

2 files changed

+16
-6
lines changed

lib/bundler/ruby_dsl.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,16 +42,16 @@ def ruby(*ruby_version)
4242
# Loads the file relative to the dirname of the Gemfile itself.
4343
def normalize_ruby_file(filename)
4444
file_content = Bundler.read_file(gemfile.dirname.join(filename))
45-
# match "ruby-3.2.2", ruby = "3.2.2" or "ruby 3.2.2" capturing version string up to the first space or comment
45+
# match "ruby-3.2.2", ruby = "3.2.2", ruby = '3.2.2' or "ruby 3.2.2" capturing version string up to the first space or comment
4646
if /^ # Start of line
4747
ruby # Literal "ruby"
4848
[\s-]* # Optional whitespace or hyphens (for "ruby-3.2.2" format)
4949
(?:=\s*)? # Optional equals sign with whitespace (for ruby = "3.2.2" format)
50-
"? # Optional opening quote
50+
["']? # Optional opening quote
5151
( # Start capturing group
52-
[^\s#"]+ # One or more chars that aren't spaces, #, or quotes
52+
[^\s#"']+ # One or more chars that aren't spaces, #, or quotes
5353
) # End capturing group
54-
"? # Optional closing quote
54+
["']? # Optional closing quote
5555
/x.match(file_content)
5656
$1
5757
else

spec/bundler/bundler/ruby_dsl_spec.rb

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -178,11 +178,21 @@ class MockDSL
178178
let(:file_content) do
179179
<<~TOML
180180
[tools]
181-
ruby = "#{version}"
181+
ruby = #{quote}#{version}#{quote}
182182
TOML
183183
end
184184

185-
it_behaves_like "it stores the ruby version"
185+
context "with double quotes" do
186+
let(:quote) { '"' }
187+
188+
it_behaves_like "it stores the ruby version"
189+
end
190+
191+
context "with single quotes" do
192+
let(:quote) { "'" }
193+
194+
it_behaves_like "it stores the ruby version"
195+
end
186196
end
187197

188198
context "with a .tool-versions file format" do

0 commit comments

Comments
 (0)