This commit is contained in:
Andrew Konchin 2025-03-26 19:56:35 +02:00 committed by Benoit Daloze
parent df08cc629e
commit 53a930f157
Notes: git 2025-03-27 10:09:42 +00:00

19
spec/mspec/tool/remove_old_guards.rb Normal file → Executable file
View File

@ -1,6 +1,23 @@
#!/usr/bin/env ruby
# Removes old version guards in ruby/spec.
# Run it from the ruby/spec repository root.
# The argument is the new minimum supported version.
#
# cd spec
# ../mspec/tool/remove_old_guards.rb <ruby-version>
#
# where <ruby-version> is a version guard with which should be removed
#
# Example:
# tool/remove_old_guards.rb 3.1
#
# As a result guards like
# ruby_version_is "3.1" do
# # ...
# end
#
# will be removed.
def dedent(line)
if line.start_with?(" ")
@ -105,6 +122,8 @@ def search(regexp)
end
end
abort "usage: #{$0} <ruby-version>" if ARGV.empty?
version = Regexp.escape(ARGV.fetch(0))
version += "(?:\\.0)?" if version.count(".") < 2
remove_guards(/ruby_version_is (["'])#{version}\1 do/, true)