mirror of
https://github.com/Shopify/liquid.git
synced 2026-09-12 23:40:45 -07:00
Ruby compatibility issues
- regexp engines are different from 1.8 to 1.9, fixed the literal shorthand regexp accordingly - changed the shorthand regexp text from a match to a string scan - test_helper now loads rubygems unless RUBY_VERSION is > 1.9
This commit is contained in:
+1
-1
@@ -45,7 +45,7 @@ module Liquid
|
|||||||
PartialTemplateParser = /#{TagStart}.*?#{TagEnd}|#{VariableStart}.*?#{VariableIncompleteEnd}/
|
PartialTemplateParser = /#{TagStart}.*?#{TagEnd}|#{VariableStart}.*?#{VariableIncompleteEnd}/
|
||||||
TemplateParser = /(#{PartialTemplateParser}|#{AnyStartingTag})/
|
TemplateParser = /(#{PartialTemplateParser}|#{AnyStartingTag})/
|
||||||
VariableParser = /\[[^\]]+\]|#{VariableSegment}+\??/
|
VariableParser = /\[[^\]]+\]|#{VariableSegment}+\??/
|
||||||
LiteralShorthand = /^(?:{{{\s?)(.*?)(?:\s*}}})$/
|
LiteralShorthand = /^(?:\{\{\{\s?)(.*?)(?:\s*\}\}\})$/
|
||||||
end
|
end
|
||||||
|
|
||||||
require 'liquid/drop'
|
require 'liquid/drop'
|
||||||
|
|||||||
@@ -43,6 +43,7 @@ class RegexpTest < Test::Unit::TestCase
|
|||||||
end
|
end
|
||||||
|
|
||||||
def test_literal_shorthand_regexp
|
def test_literal_shorthand_regexp
|
||||||
assert_match "{{{ {% if 'gnomeslab' contains 'liquid' %}yes{% endif %} }}}", LiteralShorthand
|
assert_equal [["{% if 'gnomeslab' contains 'liquid' %}yes{% endif %}"]],
|
||||||
|
"{{{ {% if 'gnomeslab' contains 'liquid' %}yes{% endif %} }}}".scan(LiteralShorthand)
|
||||||
end
|
end
|
||||||
end # RegexpTest
|
end # RegexpTest
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
extras_path = File.join File.dirname(__FILE__), 'extra'
|
extras_path = File.join File.dirname(__FILE__), 'extra'
|
||||||
$LOAD_PATH.unshift(extras_path) unless $LOAD_PATH.include? extras_path
|
$LOAD_PATH.unshift(extras_path) unless $LOAD_PATH.include? extras_path
|
||||||
|
|
||||||
|
require 'rubygems' unless RUBY_VERSION =~ /^(?:1.9.*)$/
|
||||||
require 'test/unit'
|
require 'test/unit'
|
||||||
require 'test/unit/assertions'
|
require 'test/unit/assertions'
|
||||||
require 'caller'
|
require 'caller'
|
||||||
|
|||||||
Reference in New Issue
Block a user