summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuiz Eduardo Kowalski <luizeduardokowalski@gmail.com>2024-12-24 10:39:11 -0300
committergit <svn-admin@ruby-lang.org>2024-12-27 18:54:54 +0000
commit8fa1db79bd35d93140b7c1f2d7d58a946840d46f (patch)
tree07e19db6c028e62114af8d23e71018bf8e6290d1
parent6e46b9b8b3657822306a365d6538e20fcf764d9b (diff)
[rubygems/rubygems] Expand and comment the regex
https://github.com/rubygems/rubygems/commit/0dd0e93bde
-rw-r--r--lib/bundler/ruby_dsl.rb11
1 files changed, 10 insertions, 1 deletions
diff --git a/lib/bundler/ruby_dsl.rb b/lib/bundler/ruby_dsl.rb
index 1fc4981d29..cd88253f46 100644
--- a/lib/bundler/ruby_dsl.rb
+++ b/lib/bundler/ruby_dsl.rb
@@ -43,7 +43,16 @@ module Bundler
def normalize_ruby_file(filename)
file_content = Bundler.read_file(gemfile.dirname.join(filename))
# 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)
+ if /^ # Start of line
+ ruby # Literal "ruby"
+ [\s-]* # Optional whitespace or hyphens (for "ruby-3.2.2" format)
+ (?:=\s*)? # Optional equals sign with whitespace (for ruby = "3.2.2" format)
+ "? # Optional opening quote
+ ( # Start capturing group
+ [^\s#"]+ # One or more chars that aren't spaces, #, or quotes
+ ) # End capturing group
+ "? # Optional closing quote
+ /x.match(file_content)
$1
else
file_content.strip