From f49a24201c8bbcf9fcb4349174e468a673d14b98 Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Fri, 3 Apr 2020 09:42:52 +0900 Subject: [PATCH] Refined spec/mspec/tool/remove_old_guards.rb * Allow spaces around `...` * Matches quotes more precisely * Matches 0 teeny --- spec/mspec/tool/remove_old_guards.rb | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/spec/mspec/tool/remove_old_guards.rb b/spec/mspec/tool/remove_old_guards.rb index d6ed619d98..718e351e11 100644 --- a/spec/mspec/tool/remove_old_guards.rb +++ b/spec/mspec/tool/remove_old_guards.rb @@ -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}/)