mirror of
https://github.com/Shopify/liquid.git
synced 2026-09-29 15:15:19 -07:00
Fix offenses from the new version of rubocop.
This commit is contained in:
+3
-1
@@ -118,6 +118,8 @@ Style/ClassVars:
|
|||||||
Style/PerlBackrefs:
|
Style/PerlBackrefs:
|
||||||
Enabled: false
|
Enabled: false
|
||||||
|
|
||||||
|
Style/TrivialAccessors:
|
||||||
|
AllowPredicates: true
|
||||||
|
|
||||||
Style/WordArray:
|
Style/WordArray:
|
||||||
Enabled: false
|
Enabled: false
|
||||||
|
|
||||||
|
|||||||
@@ -7,44 +7,44 @@ class String # :nodoc:
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
class Array # :nodoc:
|
class Array # :nodoc:
|
||||||
def to_liquid
|
def to_liquid
|
||||||
self
|
self
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
class Hash # :nodoc:
|
class Hash # :nodoc:
|
||||||
def to_liquid
|
def to_liquid
|
||||||
self
|
self
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
class Numeric # :nodoc:
|
class Numeric # :nodoc:
|
||||||
def to_liquid
|
def to_liquid
|
||||||
self
|
self
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
class Time # :nodoc:
|
class Time # :nodoc:
|
||||||
def to_liquid
|
def to_liquid
|
||||||
self
|
self
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
class DateTime < Date # :nodoc:
|
class DateTime < Date # :nodoc:
|
||||||
def to_liquid
|
def to_liquid
|
||||||
self
|
self
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
class Date # :nodoc:
|
class Date # :nodoc:
|
||||||
def to_liquid
|
def to_liquid
|
||||||
self
|
self
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
class TrueClass
|
class TrueClass
|
||||||
def to_liquid # :nodoc:
|
def to_liquid # :nodoc:
|
||||||
self
|
self
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -42,7 +42,7 @@ module Liquid
|
|||||||
end
|
end
|
||||||
|
|
||||||
def url_encode(input)
|
def url_encode(input)
|
||||||
CGI.escape(input) rescue input
|
CGI.escape(input) unless input.nil?
|
||||||
end
|
end
|
||||||
|
|
||||||
def slice(input, offset, length = nil)
|
def slice(input, offset, length = nil)
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ module Liquid
|
|||||||
iteration = context.registers[:cycle][key]
|
iteration = context.registers[:cycle][key]
|
||||||
result = context.evaluate(@variables[iteration])
|
result = context.evaluate(@variables[iteration])
|
||||||
iteration += 1
|
iteration += 1
|
||||||
iteration = 0 if iteration >= @variables.size
|
iteration = 0 if iteration >= @variables.size
|
||||||
context.registers[:cycle][key] = iteration
|
context.registers[:cycle][key] = iteration
|
||||||
result
|
result
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -152,7 +152,7 @@ module Liquid
|
|||||||
def strict_parse(markup)
|
def strict_parse(markup)
|
||||||
p = Parser.new(markup)
|
p = Parser.new(markup)
|
||||||
@variable_name = p.consume(:id)
|
@variable_name = p.consume(:id)
|
||||||
raise SyntaxError.new(options[:locale].t("errors.syntax.for_invalid_in".freeze)) unless p.id?('in'.freeze)
|
raise SyntaxError.new(options[:locale].t("errors.syntax.for_invalid_in".freeze)) unless p.id?('in'.freeze)
|
||||||
collection_name = p.expression
|
collection_name = p.expression
|
||||||
@name = "#{@variable_name}-#{collection_name}"
|
@name = "#{@variable_name}-#{collection_name}"
|
||||||
@collection_name = Expression.parse(collection_name)
|
@collection_name = Expression.parse(collection_name)
|
||||||
|
|||||||
+1
-1
@@ -20,7 +20,7 @@ Gem::Specification.new do |s|
|
|||||||
s.test_files = Dir.glob("{test}/**/*")
|
s.test_files = Dir.glob("{test}/**/*")
|
||||||
s.files = Dir.glob("{lib}/**/*") + %w(MIT-LICENSE README.md)
|
s.files = Dir.glob("{lib}/**/*") + %w(MIT-LICENSE README.md)
|
||||||
|
|
||||||
s.extra_rdoc_files = ["History.md", "README.md"]
|
s.extra_rdoc_files = ["History.md", "README.md"]
|
||||||
|
|
||||||
s.require_path = "lib"
|
s.require_path = "lib"
|
||||||
|
|
||||||
|
|||||||
@@ -29,10 +29,10 @@ class IfElseTagTest < Minitest::Test
|
|||||||
assert_template_result(' YES ', '{% if a or b %} YES {% endif %}', 'a' => true, 'b' => true)
|
assert_template_result(' YES ', '{% if a or b %} YES {% endif %}', 'a' => true, 'b' => true)
|
||||||
assert_template_result(' YES ', '{% if a or b %} YES {% endif %}', 'a' => true, 'b' => false)
|
assert_template_result(' YES ', '{% if a or b %} YES {% endif %}', 'a' => true, 'b' => false)
|
||||||
assert_template_result(' YES ', '{% if a or b %} YES {% endif %}', 'a' => false, 'b' => true)
|
assert_template_result(' YES ', '{% if a or b %} YES {% endif %}', 'a' => false, 'b' => true)
|
||||||
assert_template_result('', '{% if a or b %} YES {% endif %}', 'a' => false, 'b' => false)
|
assert_template_result('', '{% if a or b %} YES {% endif %}', 'a' => false, 'b' => false)
|
||||||
|
|
||||||
assert_template_result(' YES ', '{% if a or b or c %} YES {% endif %}', 'a' => false, 'b' => false, 'c' => true)
|
assert_template_result(' YES ', '{% if a or b or c %} YES {% endif %}', 'a' => false, 'b' => false, 'c' => true)
|
||||||
assert_template_result('', '{% if a or b or c %} YES {% endif %}', 'a' => false, 'b' => false, 'c' => false)
|
assert_template_result('', '{% if a or b or c %} YES {% endif %}', 'a' => false, 'b' => false, 'c' => false)
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_if_or_with_operators
|
def test_if_or_with_operators
|
||||||
|
|||||||
@@ -267,7 +267,7 @@ class ContextUnitTest < Minitest::Test
|
|||||||
|
|
||||||
def test_access_hashes_with_hash_notation
|
def test_access_hashes_with_hash_notation
|
||||||
@context['products'] = { 'count' => 5, 'tags' => ['deepsnow', 'freestyle'] }
|
@context['products'] = { 'count' => 5, 'tags' => ['deepsnow', 'freestyle'] }
|
||||||
@context['product'] = { 'variants' => [ { 'title' => 'draft151cm' }, { 'title' => 'element151cm' } ] }
|
@context['product'] = { 'variants' => [ { 'title' => 'draft151cm' }, { 'title' => 'element151cm' } ] }
|
||||||
|
|
||||||
assert_equal 5, @context['products["count"]']
|
assert_equal 5, @context['products["count"]']
|
||||||
assert_equal 'deepsnow', @context['products["tags"][0]']
|
assert_equal 'deepsnow', @context['products["tags"][0]']
|
||||||
@@ -305,7 +305,7 @@ class ContextUnitTest < Minitest::Test
|
|||||||
end
|
end
|
||||||
|
|
||||||
def test_first_can_appear_in_middle_of_callchain
|
def test_first_can_appear_in_middle_of_callchain
|
||||||
@context['product'] = { 'variants' => [ { 'title' => 'draft151cm' }, { 'title' => 'element151cm' } ] }
|
@context['product'] = { 'variants' => [ { 'title' => 'draft151cm' }, { 'title' => 'element151cm' } ] }
|
||||||
|
|
||||||
assert_equal 'draft151cm', @context['product.variants[0].title']
|
assert_equal 'draft151cm', @context['product.variants[0].title']
|
||||||
assert_equal 'element151cm', @context['product.variants[1].title']
|
assert_equal 'element151cm', @context['product.variants[1].title']
|
||||||
|
|||||||
Reference in New Issue
Block a user