class CucumberFM::TagFilter
Constants
- AND_PATTERN
- NOT_PATTERN
- OR_PATTERN
- TAG_PATTERN
- TOKEN
Public Instance Methods
pass?(tags)
click to toggle source
# File lib/cucumber_f_m/tag_filter.rb, line 14 def pass?(tags) if expression.nil? or expression.empty? true else evaluate_expression(tags) end end
Private Instance Methods
evaluate_expression(tags)
click to toggle source
TODO - refactoring
# File lib/cucumber_f_m/tag_filter.rb, line 27 def evaluate_expression(tags) buffer = nil buffer_array = [] buffer_negation = nil text = expression.gsub(/\s+/, ' ') while token = text.match(TOKEN) case token[0] when TAG_PATTERN throw "Error at #{expression} | token: #{token[0]} | last token: #{buffer}" unless buffer.nil? buffer = token[0] when NOT_PATTERN buffer_negation = true when OR_PATTERN buffer_array.push buffer buffer = nil when AND_PATTERN if buffer_array.empty? and buffer return(false) unless (!buffer_negation == tags.include?(buffer)) buffer = nil buffer_negation = nil true elsif !buffer_array.empty? if buffer buffer_array.push(buffer) buffer = nil end return(false) unless (!buffer_negation == buffer_array.any? { |tag| tags.include? tag }) buffer_array = [] buffer_negation = nil true else true end end text = token.post_match end if buffer_array.empty? and buffer return(false) unless (!buffer_negation == tags.include?(buffer)) buffer = nil buffer_negation = nil true elsif !buffer_array.empty? if buffer buffer_array.push(buffer) buffer = nil end return(false) unless (!buffer_negation == buffer_array.any? { |tag| tags.include? tag }) buffer_array = [] buffer_negation = nil true else true end end