Class: Cucumber::Parser::Filter

Inherits:
Object
  • Object
show all
Defined in:
lib/cucumber/parser/treetop_ext.rb

Instance Method Summary collapse

Constructor Details

#initialize(lines, options) ⇒ Filter

Returns a new instance of Filter.



16
17
18
19
20
21
# File 'lib/cucumber/parser/treetop_ext.rb', line 16

def initialize(lines, options)
  @lines = lines
  @include_tags = options[:include_tags] || []
  @exclude_tags = options[:exclude_tags] || []
  @names        = options[:scenario_names] || []
end

Instance Method Details

#accept?(syntax_node) ⇒ Boolean

Returns:

  • (Boolean)


23
24
25
26
27
# File 'lib/cucumber/parser/treetop_ext.rb', line 23

def accept?(syntax_node)
  at_line?(syntax_node) &&
  matches_tags?(syntax_node) &&
  matches_names?(syntax_node)
end

#at_line?(syntax_node) ⇒ Boolean

Returns:

  • (Boolean)


29
30
31
# File 'lib/cucumber/parser/treetop_ext.rb', line 29

def at_line?(syntax_node)
  @lines.nil? || @lines.empty? || @lines.detect{|line| syntax_node.at_line?(line)}
end

#excluded_by_tags?(syntax_node) ⇒ Boolean

Returns:

  • (Boolean)


46
47
48
# File 'lib/cucumber/parser/treetop_ext.rb', line 46

def excluded_by_tags?(syntax_node)
  @exclude_tags.any? && syntax_node.has_tags?(@exclude_tags)
end

#included_by_tags?(syntax_node) ⇒ Boolean

Returns:

  • (Boolean)


42
43
44
# File 'lib/cucumber/parser/treetop_ext.rb', line 42

def included_by_tags?(syntax_node)
  @include_tags.empty? || syntax_node.has_tags?(@include_tags)
end

#matches_names?(syntax_node) ⇒ Boolean

Returns:

  • (Boolean)


50
51
52
# File 'lib/cucumber/parser/treetop_ext.rb', line 50

def matches_names?(syntax_node)
  @names.nil? || @names.empty? || @names.detect{|name| syntax_node.matches_name?(name)}
end

#matches_tags?(syntax_node) ⇒ Boolean

Returns:

  • (Boolean)


37
38
39
40
# File 'lib/cucumber/parser/treetop_ext.rb', line 37

def matches_tags?(syntax_node)
  !excluded_by_tags?(syntax_node) &&
  included_by_tags?(syntax_node)
end

#outline_at_line?(syntax_node) ⇒ Boolean

Returns:

  • (Boolean)


33
34
35
# File 'lib/cucumber/parser/treetop_ext.rb', line 33

def outline_at_line?(syntax_node)
   @lines.nil? || @lines.empty? || @lines.detect{|line| syntax_node.outline_at_line?(line)}
end