From 693641fee8d1970abeded5dc59e22b745cfaf269 Mon Sep 17 00:00:00 2001
From: Yusuke Nakamura <yusuke1994525@gmail.com>
Date: Fri, 10 Jan 2020 01:06:06 +0900
Subject: [PATCH] Suppress deprecated warning by Object#=~ since ruby 2.6
In `Temple::Mixins::GrammerDSL::Value#Rule`, call `=~` method to
`Class` class then that causes a warning message.
This behavior introduced from ruby 2.6 with `-W` option.
(And ruby 2.7 always show a warning message)
- https://bugs.ruby-lang.org/issues/15231
- https://github.com/ruby/ruby/commit/ebff9dc10
Therefore use case-when-else clause to avoid warning.
---
lib/temple/mixins/grammar_dsl.rb | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/lib/temple/mixins/grammar_dsl.rb b/lib/temple/mixins/grammar_dsl.rb
index 0f154f5..d02aa9c 100644
--- a/lib/temple/mixins/grammar_dsl.rb
+++ b/lib/temple/mixins/grammar_dsl.rb
@@ -143,7 +143,8 @@ def Rule(rule)
start = Or.new(self)
curr = [start]
rule.each do |elem|
- if elem =~ /^(.*)(\*|\?|\+)$/
+ case elem
+ when /^(.*)(\*|\?|\+)$/
elem = Element.new(self, const_get($1))
curr.each {|c| c << elem }
elem << elem if $2 != '?'