Fix a bunch of Ruby warnings

This commit is contained in:
Florian Weingarten
2016-03-30 20:42:30 +00:00
parent bfee507005
commit d2f16d92d6
11 changed files with 89 additions and 76 deletions

View File

@@ -21,6 +21,7 @@ module Liquid
@registers = registers
@errors = []
@partial = false
@strict_variables = false
@resource_limits = resource_limits || ResourceLimits.new(Template.default_resource_limits)
squash_instance_assigns_with_environments

View File

@@ -62,16 +62,17 @@ module Liquid
end
def self.invokable_methods
unless @invokable_methods
@invokable_methods ||= begin
blacklist = Liquid::Drop.public_instance_methods + [:each]
if include?(Enumerable)
blacklist += Enumerable.public_instance_methods
blacklist -= [:sort, :count, :first, :min, :max, :include?]
end
whitelist = [:to_liquid] + (public_instance_methods - blacklist)
@invokable_methods = Set.new(whitelist.map(&:to_s))
Set.new(whitelist.map(&:to_s))
end
@invokable_methods
end
end
end

View File

@@ -1,7 +1,7 @@
module Liquid
class ParseContext
attr_accessor :partial, :locale, :line_number
attr_reader :warnings, :error_mode
attr_accessor :locale, :line_number
attr_reader :partial, :warnings, :error_mode
def initialize(options = {})
@template_options = options ? options.dup : {}

View File

@@ -48,8 +48,10 @@ module Liquid
def initialize(tag_name, markup, options)
super
@from = @limit = nil
parse_with_selected_parser(markup)
@for_block = BlockBody.new
@else_block = nil
end
def parse(tokens)

View File

@@ -20,7 +20,7 @@ module Liquid
class TagRegistry
def initialize
@tags = {}
@tags = {}
@cache = {}
end
@@ -80,11 +80,11 @@ module Liquid
end
def error_mode
@error_mode || :lax
@error_mode ||= :lax
end
def taint_mode
@taint_mode || :lax
@taint_mode ||= :lax
end
# Pass a module with filter methods which should be available
@@ -107,6 +107,7 @@ module Liquid
end
def initialize
@rethrow_errors = false
@resource_limits = ResourceLimits.new(self.class.default_resource_limits)
end

View File

@@ -4,7 +4,7 @@ module Liquid
def initialize(source, line_numbers = false)
@source = source
@line_number = 1 if line_numbers
@line_number = line_numbers ? 1 : nil
@tokens = tokenize
end