Class: Cuporter::TagNodesParser
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
-
#add_example(tag, feature, scenario_outline, example_set, example) ⇒ Object
-
#add_scenario(tag, feature, scenario) ⇒ Object
-
#close_scenario_outline ⇒ Object
-
#handle_example_set_line ⇒ Object
-
#handle_scenario_line(sub_expression) ⇒ Object
-
#initialize(file, report, filter) ⇒ TagNodesParser
constructor
A new instance of TagNodesParser.
-
#new_example_line(sub_expression) ⇒ Object
-
#new_example_set_node(sub_expression) ⇒ Object
-
#new_feature_node(sub_expression, file) ⇒ Object
sub_expression
is the paren group in the regex, dereferenced with $1 in the caller.
-
#new_scenario_outline_node(sub_expression) ⇒ Object
#clean_cuke_line, #file_relative_path, node, #parse_feature, tag_nodes
Constructor Details
#initialize(file, report, filter) ⇒ TagNodesParser
Returns a new instance of TagNodesParser.
86
87
88
89
90
91
|
# File 'lib/cuporter/tag_nodes_parser.rb', line 86
def initialize(file, report, filter)
super(file)
@filter = filter
@report = report
@doc = report.document
end
|
Instance Method Details
#add_example(tag, feature, scenario_outline, example_set, example) ⇒ Object
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
|
# File 'lib/cuporter/tag_nodes_parser.rb', line 63
def add_example(tag, feature, scenario_outline, example_set, example)
unless ( t = @report.tag_node(tag))
t = @report.add_child(Node.new_node(:Tag, @doc, 'cuke_name' => tag))
end
unless ( f = t.feature_node(feature) )
f = t.add_child(Node.new_node(:Feature, @doc, feature))
end
unless ( so = f.scenario_outline_node(scenario_outline) )
so = f.add_child(Node.new_node(:ScenarioOutline, @doc, scenario_outline))
end
example_type = :Example
unless ( es = so.example_set_node(example_set) )
es = so.add_child(Node.new_node(:Examples, @doc, example_set))
example_type = :ExampleHeader
end
es.add_child(Node.new_node(example_type, @doc, example))
end
|
#add_scenario(tag, feature, scenario) ⇒ Object
53
54
55
56
57
58
59
60
61
|
# File 'lib/cuporter/tag_nodes_parser.rb', line 53
def add_scenario(tag, feature, scenario)
unless ( t = @report.tag_node(tag))
t = @report.add_child(Node.new_node(:tag, @doc, 'cuke_name' => tag))
end
unless ( f = t.feature_node(feature) )
f = t.add_child(Node.new_node(:Feature, @doc, feature))
end
f.add_child(Node.new_node(:Scenario, @doc, scenario))
end
|
#close_scenario_outline ⇒ Object
45
46
47
48
49
50
51
52
|
# File 'lib/cuporter/tag_nodes_parser.rb', line 45
def close_scenario_outline
if @scenario_outline
if @example_set
@example_set = nil
end
@scenario_outline = nil
end
end
|
#handle_example_set_line ⇒ Object
26
27
|
# File 'lib/cuporter/tag_nodes_parser.rb', line 26
def handle_example_set_line
end
|
#handle_scenario_line(sub_expression) ⇒ Object
11
12
13
14
15
16
17
18
19
20
|
# File 'lib/cuporter/tag_nodes_parser.rb', line 11
def handle_scenario_line(sub_expression)
if @filter.pass?(@feature[:tags] | @current_tags)
s = {:cuke_name => sub_expression, :tags => @current_tags}
(@feature[:tags] | s[:tags]).each do |tag|
next unless @filter.pass?([tag])
add_scenario(tag, @feature, s)
end
end
end
|
#new_example_line(sub_expression) ⇒ Object
33
34
35
36
37
38
39
40
41
42
43
|
# File 'lib/cuporter/tag_nodes_parser.rb', line 33
def new_example_line(sub_expression)
context_tags = (@feature[:tags] | @scenario_outline[:tags] | @example_set[:tags])
if @filter.pass?(context_tags)
e = {:cuke_name => sub_expression}
context_tags.each do |tag|
next unless @filter.pass?([tag])
add_example(tag, @feature, @scenario_outline, @example_set, e)
end
end
end
|
#new_example_set_node(sub_expression) ⇒ Object
29
30
31
|
# File 'lib/cuporter/tag_nodes_parser.rb', line 29
def new_example_set_node(sub_expression)
{:cuke_name => sub_expression.to_s.strip, :tags => @current_tags}
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
|
# File 'lib/cuporter/tag_nodes_parser.rb', line 7
def new_feature_node(sub_expression, file)
{:cuke_name => sub_expression, :tags => @current_tags, :file_path => file}
end
|
#new_scenario_outline_node(sub_expression) ⇒ Object
22
23
24
|
# File 'lib/cuporter/tag_nodes_parser.rb', line 22
def new_scenario_outline_node(sub_expression)
{:cuke_name => sub_expression, :tags => @current_tags}
end
|