Class: Cucumber::Filter
Overview
Filters the AST based on –tags and –name
Instance Method Summary collapse
- #accept?(syntax_node) ⇒ Boolean
- #accept_example?(syntax_node, outline) ⇒ Boolean
- #at_line?(syntax_node) ⇒ Boolean
- #excluded_by_tags?(syntax_node) ⇒ Boolean
- #included_by_tags?(syntax_node) ⇒ Boolean
-
#initialize(lines, options) ⇒ Filter
constructor
:nodoc:.
- #matches_names?(syntax_node) ⇒ Boolean
- #matches_tags?(syntax_node) ⇒ Boolean
- #outline_at_line?(syntax_node) ⇒ Boolean
- #outline_matches_names?(syntax_node) ⇒ Boolean
Constructor Details
#initialize(lines, options) ⇒ Filter
:nodoc:
4 5 6 7 8 9 10 |
# File 'lib/cucumber/filter.rb', line 4 def initialize(lines, ) @lines = lines @include_tags = [:include_tags] ? [:include_tags].keys : [] @exclude_tags = [:exclude_tags] ? [:exclude_tags].keys : [] @name_regexps = [:name_regexps] || [] end |
Instance Method Details
#accept?(syntax_node) ⇒ Boolean
12 13 14 15 16 |
# File 'lib/cucumber/filter.rb', line 12 def accept?(syntax_node) at_line?(syntax_node) && (syntax_node) && matches_names?(syntax_node) end |
#accept_example?(syntax_node, outline) ⇒ Boolean
18 19 20 21 |
# File 'lib/cucumber/filter.rb', line 18 def accept_example?(syntax_node, outline) (at_line?(syntax_node) || outline_at_line?(outline)) && (matches_names?(syntax_node) || outline_matches_names?(outline)) end |
#at_line?(syntax_node) ⇒ Boolean
23 24 25 |
# File 'lib/cucumber/filter.rb', line 23 def at_line?(syntax_node) @lines.nil? || @lines.empty? || @lines.detect{|line| syntax_node.at_line?(line)} end |
#excluded_by_tags?(syntax_node) ⇒ Boolean
40 41 42 |
# File 'lib/cucumber/filter.rb', line 40 def (syntax_node) @exclude_tags.any? && syntax_node.(@exclude_tags) end |
#included_by_tags?(syntax_node) ⇒ Boolean
36 37 38 |
# File 'lib/cucumber/filter.rb', line 36 def (syntax_node) @include_tags.empty? || syntax_node.(@include_tags) end |
#matches_names?(syntax_node) ⇒ Boolean
48 49 50 |
# File 'lib/cucumber/filter.rb', line 48 def matches_names?(syntax_node) @name_regexps.nil? || @name_regexps.empty? || @name_regexps.detect{|name_regexp| syntax_node.matches_name?(name_regexp)} end |
#matches_tags?(syntax_node) ⇒ Boolean
31 32 33 34 |
# File 'lib/cucumber/filter.rb', line 31 def (syntax_node) !(syntax_node) && (syntax_node) end |
#outline_at_line?(syntax_node) ⇒ Boolean
27 28 29 |
# File 'lib/cucumber/filter.rb', line 27 def outline_at_line?(syntax_node) @lines.nil? || @lines.empty? || @lines.detect{|line| syntax_node.outline_at_line?(line)} end |
#outline_matches_names?(syntax_node) ⇒ Boolean
44 45 46 |
# File 'lib/cucumber/filter.rb', line 44 def outline_matches_names?(syntax_node) @name_regexps.nil? || @name_regexps.empty? || @name_regexps.detect{|name_regexp| syntax_node.outline_matches_name?(name_regexp)} end |