Skip to content

Commit

Permalink
Suppress deprecated warning by Object#=~ since ruby 2.6
Browse files Browse the repository at this point in the history
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
ruby/ruby@ebff9dc10

Therefore if "elem" is `Class` class, skip calling `=~` method.
  • Loading branch information
unasuke committed Jan 9, 2020
1 parent eff6890 commit 79f41cd
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion lib/temple/mixins/grammar_dsl.rb
Expand Up @@ -143,7 +143,7 @@ def Rule(rule)
start = Or.new(self)
curr = [start]
rule.each do |elem|
if elem =~ /^(.*)(\*|\?|\+)$/
if elem.class != Class && elem =~ /^(.*)(\*|\?|\+)$/
elem = Element.new(self, const_get($1))
curr.each {|c| c << elem }
elem << elem if $2 != '?'
Expand Down

0 comments on commit 79f41cd

Please sign in to comment.