Class: Cuporter::NodeParser
Constant Summary
FeatureParser::EXAMPLE_LINE, FeatureParser::EXAMPLE_SET_LINE, FeatureParser::FEATURE_LINE, FeatureParser::PY_STRING_LINE, FeatureParser::SCENARIO_LINE, FeatureParser::SCENARIO_OUTLINE_LINE, FeatureParser::SCENARIO_SET_LINE, FeatureParser::TAG_LINE
Instance Attribute Summary
#root
Instance Method Summary
collapse
#clean_cuke_line, #file_relative_path, node, #parse_feature, tag_nodes
Constructor Details
#initialize(file, doc, filter) ⇒ NodeParser
Returns a new instance of NodeParser.
55
56
57
58
59
|
# File 'lib/cuporter/node_parser.rb', line 55
def initialize(file, doc, filter)
super(file)
@filter = filter
@doc = doc
end
|
Instance Method Details
#close_scenario_outline ⇒ Object
44
45
46
47
48
49
50
51
52
53
|
# File 'lib/cuporter/node_parser.rb', line 44
def close_scenario_outline
if @scenario_outline
if @example_set
handle_example_set_line
@example_set = nil
end
@feature.add_child(@scenario_outline) if @scenario_outline.has_children?
@scenario_outline = nil
end
end
|
#handle_example_set_line ⇒ Object
25
26
27
28
29
|
# File 'lib/cuporter/node_parser.rb', line 25
def handle_example_set_line
if @filter.pass?(@feature.tags | @scenario_outline.tags | @example_set.tags)
@scenario_outline.add_child @example_set
end
end
|
#handle_scenario_line(sub_expression) ⇒ Object
13
14
15
16
17
|
# File 'lib/cuporter/node_parser.rb', line 13
def handle_scenario_line(sub_expression)
if @filter.pass?(@current_tags | @feature.tags)
@feature.add_child(Node.new_node(:Scenario, @doc, :cuke_name => sub_expression, :tags => @current_tags))
end
end
|
#new_example_line(sub_expression) ⇒ Object
37
38
39
40
41
42
|
# File 'lib/cuporter/node_parser.rb', line 37
def new_example_line(sub_expression)
example_type = :ExampleHeader
example_type = :Example if @example_set.has_children?
@example_set.add_child(Node.new_node(example_type, @doc, :cuke_name => sub_expression))
end
|
#new_example_set_node(sub_expression) ⇒ Object
31
32
33
34
35
|
# File 'lib/cuporter/node_parser.rb', line 31
def new_example_set_node(sub_expression)
es = Node.new_node(:Examples, @doc, :cuke_name => sub_expression, :tags => @current_tags)
es.filter = @filter
es
end
|
#new_feature_node(sub_expression, file) ⇒ Object
sub_expression
is the paren group in the regex, dereferenced with $1 in the caller
7
8
9
10
11
|
# File 'lib/cuporter/node_parser.rb', line 7
def new_feature_node(sub_expression, file)
f = Node.new_node(:Feature, @doc, :cuke_name => sub_expression, :tags => @current_tags, :file_path => file)
f.filter = @filter
f
end
|
#new_scenario_outline_node(sub_expression) ⇒ Object
19
20
21
22
23
|
# File 'lib/cuporter/node_parser.rb', line 19
def new_scenario_outline_node(sub_expression)
so = Node.new_node(:ScenarioOutline, @doc, :cuke_name => sub_expression, :tags => @current_tags)
so.filter = @filter
so
end
|