Parent

Gherkin::TagExpression

Attributes

limits[R]

Public Class Methods

new(tag_expressions) click to toggle source
    # File lib/gherkin/tag_expression.rb, line 9
 9:     def initialize(tag_expressions)
10:       @ands = []
11:       @limits = {}
12:       tag_expressions.each do |expr|
13:         add(expr.strip.split(/\s*,\s*/))
14:       end
15:     end

Public Instance Methods

empty?() click to toggle source
    # File lib/gherkin/tag_expression.rb, line 17
17:     def empty?
18:       @ands.empty?
19:     end
eval(tags) click to toggle source
    # File lib/gherkin/tag_expression.rb, line 21
21:     def eval(tags)
22:       return true if @ands.flatten.empty?
23:       vars = Hash[*tags.map{|tag| [tag, true]}.flatten]
24:       !!Kernel.eval(ruby_expression)
25:     end

Private Instance Methods

add(tags_with_negation_and_limits) click to toggle source
    # File lib/gherkin/tag_expression.rb, line 29
29:     def add(tags_with_negation_and_limits)
30:       negatives, positives = tags_with_negation_and_limits.partition{|tag| tag =~ /^~/}
31:       @ands << (store_and_extract_limits(negatives, true) + store_and_extract_limits(positives, false))
32:     end
ruby_expression() click to toggle source
    # File lib/gherkin/tag_expression.rb, line 50
50:     def ruby_expression
51:       "(" + @ands.map do |ors|
52:         ors.map do |tag|
53:           if tag =~ /^~(.*)/
54:             "!vars['#{$1}']"
55:           else
56:             "vars['#{tag}']"
57:           end
58:         end.join("||")
59:       end.join(")&&(") + ")"
60:     end
store_and_extract_limits(tags_with_negation_and_limits, negated) click to toggle source
    # File lib/gherkin/tag_expression.rb, line 34
34:     def store_and_extract_limits(tags_with_negation_and_limits, negated)
35:       tags_with_negation = []
36:       tags_with_negation_and_limits.each do |tag_with_negation_and_limit|
37:         tag_with_negation, limit = tag_with_negation_and_limit.split(':')
38:         tags_with_negation << tag_with_negation
39:         if limit
40:           tag_without_negation = negated ? tag_with_negation[1..1] : tag_with_negation
41:           if @limits[tag_without_negation] && @limits[tag_without_negation] != limit.to_i
42:             raise "Inconsistent tag limits for #{tag_without_negation}: #{@limits[tag_without_negation]} and #{limit.to_i}" 
43:           end
44:           @limits[tag_without_negation] = limit.to_i
45:         end
46:       end
47:       tags_with_negation
48:     end

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.