1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

Refined spec/mspec/tool/remove_old_guards.rb

* Allow spaces around `...`
* Matches quotes more precisely
* Matches 0 teeny
This commit is contained in:
Nobuyoshi Nakada 2020-04-03 09:42:52 +09:00
parent da05c1552e
commit f49a24201c
No known key found for this signature in database
GPG key ID: 4BC7D6DF58D8DF60
Notes: git 2020-04-03 10:37:05 +09:00

View file

@ -57,9 +57,10 @@ def search(regexp)
end
version = Regexp.escape(ARGV.fetch(0))
remove_guards(/ruby_version_is ["']#{version}["'] do/, true)
remove_guards(/ruby_version_is ["'][0-9.]*["']...["']#{version}["'] do/, false)
remove_guards(/ruby_bug "#\d+", ["'][0-9.]*["']...["']#{version}["'] do/, true)
version += "(?:\\.0)?" if version.count(".") < 2
remove_guards(/ruby_version_is (["'])#{version}\1 do/, true)
remove_guards(/ruby_version_is (["'])[0-9.]*\1 *... *(["'])#{version}\2 do/, false)
remove_guards(/ruby_bug "#\d+", (["'])[0-9.]*\1 *... *(["'])#{version}\2 do/, true)
search(/["']#{version}["']/)
search(/(["'])#{version}\1/)
search(/^\s*#.+#{version}/)