mirror of
https://github.com/kemko/liquid.git
synced 2026-01-01 15:55:40 +03:00
Expose name, lookups, and command flags from VariableLookup
This commit is contained in:
@@ -3,6 +3,8 @@ module Liquid
|
||||
SQUARE_BRACKETED = /\A\[(.*)\]\z/m
|
||||
COMMAND_METHODS = ['size'.freeze, 'first'.freeze, 'last'.freeze]
|
||||
|
||||
attr_reader :name, :lookups, :command_flags
|
||||
|
||||
def self.parse(markup)
|
||||
new(markup)
|
||||
end
|
||||
|
||||
@@ -147,4 +147,16 @@ class VariableUnitTest < Minitest::Test
|
||||
var = Variable.new(%! name_of_variable | upcase !)
|
||||
assert_equal " name_of_variable | upcase ", var.raw
|
||||
end
|
||||
|
||||
def test_variable_lookup_interface
|
||||
lookup = VariableLookup.new('a.b.c')
|
||||
assert_equal 'a', lookup.name
|
||||
assert_equal ['b', 'c'], lookup.lookups
|
||||
assert_equal 0, lookup.command_flags
|
||||
|
||||
lookup = VariableLookup.new('a.first.size')
|
||||
assert_equal 'a', lookup.name
|
||||
assert_equal ['first', 'size'], lookup.lookups
|
||||
assert_equal 0b11, lookup.command_flags
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user