cucumber-gherkin 29.0.0 → 30.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/bin/gherkin +11 -10
- data/lib/gherkin/ast_builder.rb +22 -15
- data/lib/gherkin/dialect.rb +2 -1
- data/lib/gherkin/errors.rb +1 -1
- data/lib/gherkin/gherkin_line.rb +3 -4
- data/lib/gherkin/parser.rb +370 -370
- data/lib/gherkin/pickles/compiler.rb +4 -7
- data/lib/gherkin/query.rb +4 -0
- data/lib/gherkin/stream/parser_message_stream.rb +14 -13
- data/lib/gherkin/token_formatter_builder.rb +9 -9
- data/lib/gherkin/token_matcher.rb +10 -12
- data/lib/gherkin/token_scanner.rb +2 -3
- data/lib/gherkin.rb +9 -11
- metadata +6 -6
@@ -11,6 +11,7 @@ module Gherkin
|
|
11
11
|
pickles = []
|
12
12
|
|
13
13
|
return pickles unless gherkin_document.feature
|
14
|
+
|
14
15
|
feature = gherkin_document.feature
|
15
16
|
language = feature.language
|
16
17
|
tags = feature.tags
|
@@ -143,9 +144,7 @@ module Gherkin
|
|
143
144
|
type: keyword_type,
|
144
145
|
text: interpolate(step.text, variable_cells, value_cells),
|
145
146
|
}
|
146
|
-
if values_row
|
147
|
-
props[:ast_node_ids].push(values_row.id)
|
148
|
-
end
|
147
|
+
props[:ast_node_ids].push(values_row.id) if values_row
|
149
148
|
|
150
149
|
if step.data_table
|
151
150
|
data_table = Cucumber::Messages::PickleStepArgument.new(
|
@@ -180,14 +179,12 @@ module Gherkin
|
|
180
179
|
props = {
|
181
180
|
content: interpolate(doc_string.content, variable_cells, value_cells)
|
182
181
|
}
|
183
|
-
if doc_string.media_type
|
184
|
-
props[:media_type] = interpolate(doc_string.media_type, variable_cells, value_cells)
|
185
|
-
end
|
182
|
+
props[:media_type] = interpolate(doc_string.media_type, variable_cells, value_cells) if doc_string.media_type
|
186
183
|
Cucumber::Messages::PickleDocString.new(**props)
|
187
184
|
end
|
188
185
|
|
189
186
|
def pickle_tags(tags)
|
190
|
-
tags.map {|tag| pickle_tag(tag)}
|
187
|
+
tags.map { |tag| pickle_tag(tag) }
|
191
188
|
end
|
192
189
|
|
193
190
|
def pickle_tag(tag)
|
data/lib/gherkin/query.rb
CHANGED
@@ -12,11 +12,13 @@ module Gherkin
|
|
12
12
|
|
13
13
|
def scenario_parent_locations(scenario_node_id)
|
14
14
|
return @scenario_parent_locations[scenario_node_id] if @scenario_parent_locations.has_key?(scenario_node_id)
|
15
|
+
|
15
16
|
raise AstNodeNotLocatedException, "No scenario parent locations found for #{scenario_node_id} }. Known: #{@scenario_parent_locations.keys}"
|
16
17
|
end
|
17
18
|
|
18
19
|
def location(ast_node_id)
|
19
20
|
return @ast_node_locations[ast_node_id] if @ast_node_locations.has_key?(ast_node_id)
|
21
|
+
|
20
22
|
raise AstNodeNotLocatedException, "No location found for #{ast_node_id} }. Known: #{@ast_node_locations.keys}"
|
21
23
|
end
|
22
24
|
|
@@ -24,6 +26,7 @@ module Gherkin
|
|
24
26
|
|
25
27
|
def update_feature(feature)
|
26
28
|
return if feature.nil?
|
29
|
+
|
27
30
|
store_nodes_location(feature.tags)
|
28
31
|
|
29
32
|
feature.children.each do |child|
|
@@ -35,6 +38,7 @@ module Gherkin
|
|
35
38
|
|
36
39
|
def update_rule(feature, rule)
|
37
40
|
return if rule.nil?
|
41
|
+
|
38
42
|
store_nodes_location(rule.tags)
|
39
43
|
rule.children.each do |child|
|
40
44
|
update_background(rule, child.background) if child.background
|
@@ -18,30 +18,31 @@ module Gherkin
|
|
18
18
|
|
19
19
|
def messages
|
20
20
|
enumerated = false
|
21
|
-
Enumerator.new do |
|
21
|
+
Enumerator.new do |yielder|
|
22
22
|
raise DoubleIterationException, "Messages have already been enumerated" if enumerated
|
23
|
+
|
23
24
|
enumerated = true
|
24
25
|
|
25
26
|
sources.each do |source|
|
26
|
-
|
27
|
+
yielder.yield(Cucumber::Messages::Envelope.new(source: source)) if @options[:include_source]
|
27
28
|
begin
|
28
29
|
gherkin_document = nil
|
29
30
|
|
30
31
|
if @options[:include_gherkin_document]
|
31
32
|
gherkin_document = build_gherkin_document(source)
|
32
|
-
|
33
|
+
yielder.yield(Cucumber::Messages::Envelope.new(gherkin_document: gherkin_document))
|
33
34
|
end
|
34
35
|
if @options[:include_pickles]
|
35
36
|
gherkin_document ||= build_gherkin_document(source)
|
36
37
|
pickles = @compiler.compile(gherkin_document, source)
|
37
38
|
pickles.each do |pickle|
|
38
|
-
|
39
|
+
yielder.yield(Cucumber::Messages::Envelope.new(pickle: pickle))
|
39
40
|
end
|
40
41
|
end
|
41
|
-
rescue CompositeParserException =>
|
42
|
-
yield_parse_errors(
|
43
|
-
rescue ParserException =>
|
44
|
-
yield_parse_errors(
|
42
|
+
rescue CompositeParserException => e
|
43
|
+
yield_parse_errors(yielder, e.errors, source.uri)
|
44
|
+
rescue ParserException => e
|
45
|
+
yield_parse_errors(yielder, [e], source.uri)
|
45
46
|
end
|
46
47
|
end
|
47
48
|
end
|
@@ -49,7 +50,7 @@ module Gherkin
|
|
49
50
|
|
50
51
|
private
|
51
52
|
|
52
|
-
def yield_parse_errors(
|
53
|
+
def yield_parse_errors(yielder, errors, uri)
|
53
54
|
errors.each do |err|
|
54
55
|
parse_error = Cucumber::Messages::ParseError.new(
|
55
56
|
source: Cucumber::Messages::SourceReference.new(
|
@@ -61,22 +62,22 @@ module Gherkin
|
|
61
62
|
),
|
62
63
|
message: err.message
|
63
64
|
)
|
64
|
-
|
65
|
+
yielder.yield(Cucumber::Messages::Envelope.new(parse_error: parse_error))
|
65
66
|
end
|
66
67
|
end
|
67
68
|
|
68
69
|
def sources
|
69
|
-
Enumerator.new do |
|
70
|
+
Enumerator.new do |yielder|
|
70
71
|
@paths.each do |path|
|
71
72
|
source = Cucumber::Messages::Source.new(
|
72
73
|
uri: path,
|
73
74
|
data: File.open(path, 'r:UTF-8', &:read),
|
74
75
|
media_type: 'text/x.cucumber.gherkin+plain'
|
75
76
|
)
|
76
|
-
|
77
|
+
yielder.yield(source)
|
77
78
|
end
|
78
79
|
@sources.each do |source|
|
79
|
-
|
80
|
+
yielder.yield(source)
|
80
81
|
end
|
81
82
|
end
|
82
83
|
end
|
@@ -5,35 +5,35 @@ module Gherkin
|
|
5
5
|
end
|
6
6
|
|
7
7
|
def reset
|
8
|
-
@tokens_text =
|
8
|
+
@tokens_text = ''
|
9
9
|
end
|
10
10
|
|
11
11
|
def build(token)
|
12
12
|
@tokens_text << "#{format_token(token)}\n"
|
13
13
|
end
|
14
14
|
|
15
|
-
def start_rule(
|
16
|
-
end
|
15
|
+
def start_rule(_rule_type); end
|
17
16
|
|
18
|
-
def end_rule(
|
19
|
-
end
|
17
|
+
def end_rule(_rule_type); end
|
20
18
|
|
21
19
|
def get_result
|
22
20
|
@tokens_text
|
23
21
|
end
|
24
22
|
|
25
23
|
private
|
24
|
+
|
26
25
|
def format_token(token)
|
27
|
-
return
|
26
|
+
return 'EOF' if token.eof?
|
28
27
|
|
29
|
-
sprintf
|
28
|
+
sprintf(
|
29
|
+
"(%s:%s)%s:%s/%s/%s",
|
30
30
|
token.location[:line],
|
31
31
|
token.location[:column],
|
32
32
|
token.matched_type,
|
33
33
|
token.matched_keyword ? sprintf("(%s)%s", token.matched_keyword_type, token.matched_keyword) : "",
|
34
34
|
token.matched_text,
|
35
|
-
Array(token.matched_items).map { |i| "#{i.column}:#{i.text}"}.join(',')
|
35
|
+
Array(token.matched_items).map { |i| "#{i.column}:#{i.text}" }.join(',')
|
36
|
+
)
|
36
37
|
end
|
37
|
-
|
38
38
|
end
|
39
39
|
end
|
@@ -48,21 +48,22 @@ module Gherkin
|
|
48
48
|
|
49
49
|
def match_TableRow(token)
|
50
50
|
return false unless token.line.start_with?('|')
|
51
|
-
|
52
|
-
set_token_matched(token, :TableRow, nil, nil, nil, nil,
|
53
|
-
token.line.table_cells)
|
51
|
+
|
52
|
+
set_token_matched(token, :TableRow, nil, nil, nil, nil, token.line.table_cells)
|
54
53
|
true
|
55
54
|
end
|
56
55
|
|
57
56
|
def match_Empty(token)
|
58
57
|
return false unless token.line.empty?
|
58
|
+
|
59
59
|
set_token_matched(token, :Empty, nil, nil, 0)
|
60
60
|
true
|
61
61
|
end
|
62
62
|
|
63
63
|
def match_Comment(token)
|
64
64
|
return false unless token.line.start_with?('#')
|
65
|
-
|
65
|
+
|
66
|
+
text = token.line.get_line_text(0) # take the entire line, including leading space
|
66
67
|
set_token_matched(token, :Comment, text, nil, 0)
|
67
68
|
true
|
68
69
|
end
|
@@ -70,7 +71,7 @@ module Gherkin
|
|
70
71
|
def match_Language(token)
|
71
72
|
return false unless token.line.trimmed_line_text =~ LANGUAGE_PATTERN
|
72
73
|
|
73
|
-
dialect_name =
|
74
|
+
dialect_name = Regexp.last_match(1)
|
74
75
|
set_token_matched(token, :Language, dialect_name)
|
75
76
|
|
76
77
|
change_dialect(dialect_name, token.location)
|
@@ -108,6 +109,7 @@ module Gherkin
|
|
108
109
|
|
109
110
|
def match_EOF(token)
|
110
111
|
return false unless token.eof?
|
112
|
+
|
111
113
|
set_token_matched(token, :EOF)
|
112
114
|
true
|
113
115
|
end
|
@@ -132,22 +134,18 @@ module Gherkin
|
|
132
134
|
title = token.line.get_rest_trimmed(keyword.length)
|
133
135
|
keyword_types = @keyword_types[keyword]
|
134
136
|
keyword_type = keyword_types[0]
|
135
|
-
if keyword_types.length
|
136
|
-
keyword_type = Cucumber::Messages::StepKeywordType::UNKNOWN
|
137
|
-
end
|
137
|
+
keyword_type = Cucumber::Messages::StepKeywordType::UNKNOWN if keyword_types.length > 1
|
138
138
|
|
139
139
|
set_token_matched(token,
|
140
140
|
:StepLine, title, keyword, nil, keyword_type)
|
141
|
-
|
141
|
+
true
|
142
142
|
end
|
143
143
|
|
144
144
|
private
|
145
145
|
|
146
146
|
def add_keyword_type_mappings(keywords, type)
|
147
147
|
keywords.each do |keyword|
|
148
|
-
|
149
|
-
@keyword_types[keyword] = []
|
150
|
-
end
|
148
|
+
@keyword_types[keyword] = [] unless @keyword_types.has_key?(keyword)
|
151
149
|
@keyword_types[keyword] += [type]
|
152
150
|
end
|
153
151
|
end
|
@@ -14,7 +14,7 @@ module Gherkin
|
|
14
14
|
def initialize(source_or_io)
|
15
15
|
@line_number = 0
|
16
16
|
|
17
|
-
case
|
17
|
+
case source_or_io
|
18
18
|
when String
|
19
19
|
@io = StringIO.new(source_or_io)
|
20
20
|
when StringIO, IO
|
@@ -25,7 +25,7 @@ module Gherkin
|
|
25
25
|
end
|
26
26
|
|
27
27
|
def read
|
28
|
-
location = {line: @line_number += 1}
|
28
|
+
location = { line: @line_number += 1 }
|
29
29
|
if @io.nil? || line = @io.gets
|
30
30
|
gherkin_line = line ? GherkinLine.new(line, location[:line]) : nil
|
31
31
|
Token.new(gherkin_line, location)
|
@@ -35,6 +35,5 @@ module Gherkin
|
|
35
35
|
Token.new(nil, location)
|
36
36
|
end
|
37
37
|
end
|
38
|
-
|
39
38
|
end
|
40
39
|
end
|
data/lib/gherkin.rb
CHANGED
@@ -7,28 +7,26 @@ module Gherkin
|
|
7
7
|
include_pickles: true
|
8
8
|
}.freeze
|
9
9
|
|
10
|
-
def self.from_paths(paths, options={})
|
10
|
+
def self.from_paths(paths, options = {})
|
11
11
|
Stream::ParserMessageStream.new(
|
12
|
-
|
13
|
-
|
14
|
-
|
12
|
+
paths,
|
13
|
+
[],
|
14
|
+
options
|
15
15
|
).messages
|
16
16
|
end
|
17
17
|
|
18
|
-
def self.from_sources(sources, options={})
|
18
|
+
def self.from_sources(sources, options = {})
|
19
19
|
Stream::ParserMessageStream.new(
|
20
|
-
|
21
|
-
|
22
|
-
|
20
|
+
[],
|
21
|
+
sources,
|
22
|
+
options
|
23
23
|
).messages
|
24
24
|
end
|
25
25
|
|
26
|
-
def self.from_source(uri, data, options={})
|
26
|
+
def self.from_source(uri, data, options = {})
|
27
27
|
from_sources([encode_source_message(uri, data)], options)
|
28
28
|
end
|
29
29
|
|
30
|
-
private
|
31
|
-
|
32
30
|
def self.encode_source_message(uri, data)
|
33
31
|
Cucumber::Messages::Source.new(
|
34
32
|
uri: uri,
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cucumber-gherkin
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 30.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Gáspár Nagy
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2024-
|
13
|
+
date: 2024-10-24 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: cucumber-messages
|
@@ -21,7 +21,7 @@ dependencies:
|
|
21
21
|
version: '25'
|
22
22
|
- - "<"
|
23
23
|
- !ruby/object:Gem::Version
|
24
|
-
version: '
|
24
|
+
version: '28'
|
25
25
|
type: :runtime
|
26
26
|
prerelease: false
|
27
27
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -31,7 +31,7 @@ dependencies:
|
|
31
31
|
version: '25'
|
32
32
|
- - "<"
|
33
33
|
- !ruby/object:Gem::Version
|
34
|
-
version: '
|
34
|
+
version: '28'
|
35
35
|
- !ruby/object:Gem::Dependency
|
36
36
|
name: rake
|
37
37
|
requirement: !ruby/object:Gem::Requirement
|
@@ -126,8 +126,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
126
126
|
- !ruby/object:Gem::Version
|
127
127
|
version: 3.2.8
|
128
128
|
requirements: []
|
129
|
-
rubygems_version: 3.5.
|
129
|
+
rubygems_version: 3.5.16
|
130
130
|
signing_key:
|
131
131
|
specification_version: 4
|
132
|
-
summary: cucumber-gherkin-
|
132
|
+
summary: cucumber-gherkin-30.0.0
|
133
133
|
test_files: []
|