Merge pull request #73 from ruby/ak/polish-the-remove-old-guards-script · ruby/mspec@484310d (original) (raw)

Original file line number Diff line number Diff line change
@@ -1,6 +1,23 @@
1 +#!/usr/bin/env ruby
2 +
1 3 # Removes old version guards in ruby/spec.
2 4 # Run it from the ruby/spec repository root.
3 5 # The argument is the new minimum supported version.
6 +#
7 +# cd spec
8 +# ../mspec/tool/remove_old_guards.rb
9 +#
10 +# where is a version guard with which should be removed
11 +#
12 +# Example:
13 +# tool/remove_old_guards.rb 3.1
14 +#
15 +# As a result guards like
16 +# ruby_version_is "3.1" do
17 +# # ...
18 +# end
19 +#
20 +# will be removed.
4 21
5 22 def dedent(line)
6 23 if line.start_with?(" ")
@@ -105,6 +122,8 @@ def search(regexp)
105 122 end
106 123 end
107 124
125 +abort "usage: #{$0} " if ARGV.empty?
126 +
108 127 version = Regexp.escape(ARGV.fetch(0))
109 128 version += "(?:\\.0)?" if version.count(".") < 2
110 129 remove_guards(/ruby_version_is (["'])#{version}\1 do/, true)