From 313d01706acff3b2cbb3a1e7dd89eaac3b4135f6 Mon Sep 17 00:00:00 2001 From: Michael Go Date: Mon, 25 Nov 2024 15:56:22 -0400 Subject: [PATCH] code styling --- lib/liquid.rb | 3 +++ lib/liquid/expression.rb | 3 ++- lib/liquid/lexer.rb | 4 +--- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/lib/liquid.rb b/lib/liquid.rb index 367fc3c4..4d0a71a6 100644 --- a/lib/liquid.rb +++ b/lib/liquid.rb @@ -21,6 +21,8 @@ # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +require "strscan" + module Liquid FilterSeparator = /\|/ ArgumentSeparator = ',' @@ -44,6 +46,7 @@ module Liquid VariableParser = /\[(?>[^\[\]]+|\g<0>)*\]|#{VariableSegment}+\??/o RAISE_EXCEPTION_LAMBDA = ->(_e) { raise } + HAS_STRING_SCANNER_SCAN_BYTE = StringScanner.instance_methods.include?(:scan_byte) end require "liquid/version" diff --git a/lib/liquid/expression.rb b/lib/liquid/expression.rb index 2bef9cb5..8eb1f2c3 100644 --- a/lib/liquid/expression.rb +++ b/lib/liquid/expression.rb @@ -160,5 +160,6 @@ module Liquid end end - Expression = StringScanner.instance_methods.include?(:scan_byte) ? Expression2 : Expression1 + # Remove this once we can depend on strscan >= 3.1.1 + Expression = HAS_STRING_SCANNER_SCAN_BYTE ? Expression2 : Expression1 end diff --git a/lib/liquid/lexer.rb b/lib/liquid/lexer.rb index 3b23f5ff..ac4a0b8f 100644 --- a/lib/liquid/lexer.rb +++ b/lib/liquid/lexer.rb @@ -1,7 +1,5 @@ # frozen_string_literal: true -require "strscan" - module Liquid class Lexer1 SPECIALS = { @@ -229,5 +227,5 @@ module Liquid end # Remove this once we can depend on strscan >= 3.1.1 - Lexer = StringScanner.instance_methods.include?(:scan_byte) ? Lexer2 : Lexer1 + Lexer = HAS_STRING_SCANNER_SCAN_BYTE ? Lexer2 : Lexer1 end