Skip to content
Merged
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
19 changes: 19 additions & 0 deletions tool/remove_old_guards.rb
100644 → 100755
Original file line number Diff line number Diff line change
@@ -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?(" ")
Expand Down Expand Up @@ -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)
Expand Down