Skip to content

Commit

Permalink
Ruby compatibility issues
Browse files Browse the repository at this point in the history
  - 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
  • Loading branch information
DBA authored and Tobias Lütke committed Aug 24, 2010
1 parent 772233d commit 3d43efe
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/liquid.rb
Expand Up @@ -45,7 +45,7 @@ module Liquid
PartialTemplateParser = /#{TagStart}.*?#{TagEnd}|#{VariableStart}.*?#{VariableIncompleteEnd}/
TemplateParser = /(#{PartialTemplateParser}|#{AnyStartingTag})/
VariableParser = /\[[^\]]+\]|#{VariableSegment}+\??/
LiteralShorthand = /^(?:{{{\s?)(.*?)(?:\s*}}})$/
LiteralShorthand = /^(?:\{\{\{\s?)(.*?)(?:\s*\}\}\})$/
end

require 'liquid/drop'
Expand Down
3 changes: 2 additions & 1 deletion test/lib/liquid/regexp_test.rb
Expand Up @@ -43,6 +43,7 @@ def test_variable_parser
end

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 # RegexpTest
1 change: 1 addition & 0 deletions test/test_helper.rb
Expand Up @@ -2,6 +2,7 @@
extras_path = File.join File.dirname(__FILE__), 'extra'
$LOAD_PATH.unshift(extras_path) unless $LOAD_PATH.include? extras_path

require 'rubygems' unless RUBY_VERSION =~ /^(?:1.9.*)$/
require 'test/unit'
require 'test/unit/assertions'
require 'caller'
Expand Down

0 comments on commit 3d43efe

Please sign in to comment.