From 4684478e94f92726bbd90b099b3c2f5321d1a7d4 Mon Sep 17 00:00:00 2001 From: Ashwin Maroli Date: Mon, 29 Apr 2019 23:45:45 +0530 Subject: [PATCH 1/3] Use a private constant to stash token-types --- lib/liquid/parser.rb | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/liquid/parser.rb b/lib/liquid/parser.rb index 6954343..152e04c 100644 --- a/lib/liquid/parser.rb +++ b/lib/liquid/parser.rb @@ -44,11 +44,14 @@ module Liquid tok[0] == type end + CONSUME_TOKENS = [:string, :number] + private_constant :CONSUME_TOKENS + def expression token = @tokens[@p] if token[0] == :id variable_signature - elsif [:string, :number].include? token[0] + elsif CONSUME_TOKENS.include? token[0] consume elsif token.first == :open_round consume From 9ef6f9b642dfc0769bdb058bacf0e57f882839e6 Mon Sep 17 00:00:00 2001 From: Ashwin Maroli Date: Mon, 29 Apr 2019 23:50:49 +0530 Subject: [PATCH 2/3] Freeze mutable object assigned to constant --- lib/liquid/parser.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/liquid/parser.rb b/lib/liquid/parser.rb index 152e04c..2bc4f95 100644 --- a/lib/liquid/parser.rb +++ b/lib/liquid/parser.rb @@ -44,7 +44,7 @@ module Liquid tok[0] == type end - CONSUME_TOKENS = [:string, :number] + CONSUME_TOKENS = [:string, :number].freeze private_constant :CONSUME_TOKENS def expression From 2c424476597b03d65e87cef272d7505e5184aad4 Mon Sep 17 00:00:00 2001 From: Ashwin Maroli Date: Fri, 17 May 2019 23:30:24 +0530 Subject: [PATCH 3/3] Rename constant to SINGLE_TOKEN_EXPRESSION_TYPES --- lib/liquid/parser.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/liquid/parser.rb b/lib/liquid/parser.rb index 2bc4f95..16df6e9 100644 --- a/lib/liquid/parser.rb +++ b/lib/liquid/parser.rb @@ -44,14 +44,14 @@ module Liquid tok[0] == type end - CONSUME_TOKENS = [:string, :number].freeze - private_constant :CONSUME_TOKENS + SINGLE_TOKEN_EXPRESSION_TYPES = [:string, :number].freeze + private_constant :SINGLE_TOKEN_EXPRESSION_TYPES def expression token = @tokens[@p] if token[0] == :id variable_signature - elsif CONSUME_TOKENS.include? token[0] + elsif SINGLE_TOKEN_EXPRESSION_TYPES.include? token[0] consume elsif token.first == :open_round consume