Skip to content

Commit c78c616

Browse files
committed
Polish the tool/remove_old_guards.rb script
1 parent 0aabb3e commit c78c616

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

tool/remove_old_guards.rb

100644100755
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,22 @@
1+
#!/usr/bin/env ruby
2+
13
# Removes old version guards in ruby/spec.
24
# Run it from the ruby/spec repository root.
35
# The argument is the new minimum supported version.
6+
#
7+
# tool/remove_old_guards.rb <ruby-version>
8+
#
9+
# where <ruby-version> is a version guard with which should be removed
10+
#
11+
# Example:
12+
# tool/remove_old_guards.rb 3.1
13+
#
14+
# As a result guards like
15+
# ruby_version_is "3.1" do
16+
# # ...
17+
# end
18+
#
19+
# will be removed.
420

521
def dedent(line)
622
if line.start_with?(" ")
@@ -105,6 +121,11 @@ def search(regexp)
105121
end
106122
end
107123

124+
if ARGV.empty?
125+
puts "usage: #{$0} <ruby-version>"
126+
abort
127+
end
128+
108129
version = Regexp.escape(ARGV.fetch(0))
109130
version += "(?:\\.0)?" if version.count(".") < 2
110131
remove_guards(/ruby_version_is (["'])#{version}\1 do/, true)

0 commit comments

Comments
 (0)