Class: Cuporter::NameListParser

Inherits:
FeatureParser show all
Defined in:
lib/cuporter/name_list_parser.rb

Constant Summary

Constants inherited from FeatureParser

FeatureParser::EXAMPLE_LINE, FeatureParser::EXAMPLE_SET_LINE, FeatureParser::FEATURE_LINE, FeatureParser::SCENARIO_LINE, FeatureParser::SCENARIO_OUTLINE_LINE, FeatureParser::SCENARIO_SET_LINE, FeatureParser::TAG_LINE

Instance Method Summary collapse

Methods inherited from FeatureParser

name_list, #parse_feature, tag_list

Constructor Details

#initialize(file, filter) ⇒ NameListParser

Returns a new instance of NameListParser.



38
39
40
41
# File 'lib/cuporter/name_list_parser.rb', line 38

def initialize(file, filter)
  super(file)
  @filter = filter
end

Instance Method Details

#close_scenario_outlineObject



27
28
29
30
31
32
33
34
35
36
# File 'lib/cuporter/name_list_parser.rb', line 27

def close_scenario_outline
  if @scenario_outline
    if @example_set
      @scenario_outline.filter_child(@example_set, @example_set.tags) if @example_set
      @example_set = nil
    end
    @feature.add_child(@scenario_outline) if @scenario_outline.has_children?
    @scenario_outline = nil
  end
end

#handle_example_set_lineObject



19
20
21
# File 'lib/cuporter/name_list_parser.rb', line 19

def handle_example_set_line
  @scenario_outline.filter_child(@example_set, @example_set.tags)
end

#handle_scenario_line(sub_expression) ⇒ Object



11
12
13
# File 'lib/cuporter/name_list_parser.rb', line 11

def handle_scenario_line(sub_expression)
  @feature.filter_child(Node.new(sub_expression), @current_tags)
end

#new_example_set_node(sub_expression) ⇒ Object



23
24
25
# File 'lib/cuporter/name_list_parser.rb', line 23

def new_example_set_node(sub_expression)
  ExampleSetNode.new(sub_expression, @feature.tags | @current_tags, @filter)
end

#new_feature_node(sub_expression) ⇒ Object

sub_expression is the paren group in the regex, dereferenced with $1 in the caller



7
8
9
# File 'lib/cuporter/name_list_parser.rb', line 7

def new_feature_node(sub_expression)
  TagListNode.new(sub_expression, @current_tags, @filter)
end

#new_scenario_outline_node(sub_expression) ⇒ Object



15
16
17
# File 'lib/cuporter/name_list_parser.rb', line 15

def new_scenario_outline_node(sub_expression)
  TagListNode.new(sub_expression, @current_tags, @filter)
end