gherkin 5.1.0 → 6.0.10
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -4
- data/bin/gherkin +43 -16
- data/gherkin-go/gherkin-go-darwin-386 +0 -0
- data/gherkin-go/gherkin-go-darwin-amd64 +0 -0
- data/gherkin-go/gherkin-go-freebsd-386 +0 -0
- data/gherkin-go/gherkin-go-freebsd-amd64 +0 -0
- data/gherkin-go/gherkin-go-freebsd-arm +0 -0
- data/gherkin-go/gherkin-go-linux-386 +0 -0
- data/gherkin-go/gherkin-go-linux-amd64 +0 -0
- data/gherkin-go/gherkin-go-linux-arm +0 -0
- data/gherkin-go/gherkin-go-linux-mips +2 -0
- data/gherkin-go/gherkin-go-linux-mips64 +2 -0
- data/gherkin-go/gherkin-go-linux-mips64le +2 -0
- data/gherkin-go/gherkin-go-linux-mipsle +2 -0
- data/gherkin-go/gherkin-go-linux-s390x +2 -0
- data/gherkin-go/gherkin-go-netbsd-386 +0 -0
- data/gherkin-go/gherkin-go-netbsd-amd64 +0 -0
- data/gherkin-go/gherkin-go-netbsd-arm +0 -0
- data/gherkin-go/gherkin-go-openbsd-386 +0 -0
- data/gherkin-go/gherkin-go-openbsd-amd64 +0 -0
- data/gherkin-go/gherkin-go-windows-386.exe +0 -0
- data/gherkin-go/gherkin-go-windows-amd64.exe +0 -0
- data/lib/gherkin/dialect.rb +16 -2
- data/lib/gherkin/exe_file_path.rb +3 -0
- data/lib/gherkin/gherkin.rb +75 -0
- data/lib/gherkin/protobuf_cucumber_messages.rb +30 -0
- data/spec/capture_warnings.rb +11 -5
- data/spec/coverage.rb +3 -6
- data/spec/gherkin/dialect_spec.rb +13 -0
- data/spec/gherkin/gherkin_spec.rb +354 -0
- metadata +49 -27
- data/lib/gherkin/ast_builder.rb +0 -257
- data/lib/gherkin/ast_node.rb +0 -30
- data/lib/gherkin/errors.rb +0 -45
- data/lib/gherkin/gherkin-languages.json +0 -3239
- data/lib/gherkin/gherkin_line.rb +0 -95
- data/lib/gherkin/parser.rb +0 -2310
- data/lib/gherkin/pickles/compiler.rb +0 -163
- data/lib/gherkin/stream/gherkin_events.rb +0 -71
- data/lib/gherkin/stream/source_events.rb +0 -26
- data/lib/gherkin/token.rb +0 -18
- data/lib/gherkin/token_formatter_builder.rb +0 -39
- data/lib/gherkin/token_matcher.rb +0 -169
- data/lib/gherkin/token_scanner.rb +0 -40
- data/spec/gherkin/parser_spec.rb +0 -280
- data/spec/gherkin/stream/gherkin_events_spec.rb +0 -27
- data/spec/gherkin/stream/test_fr.feature +0 -3
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gherkin
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 6.0.10
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Gáspár Nagy
|
@@ -10,22 +10,36 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2018-
|
13
|
+
date: 2018-09-23 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: cucumber-messages
|
17
|
+
requirement: !ruby/object:Gem::Requirement
|
18
|
+
requirements:
|
19
|
+
- - '='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: 1.0.0
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
requirements:
|
26
|
+
- - '='
|
27
|
+
- !ruby/object:Gem::Version
|
28
|
+
version: 1.0.0
|
15
29
|
- !ruby/object:Gem::Dependency
|
16
30
|
name: bundler
|
17
31
|
requirement: !ruby/object:Gem::Requirement
|
18
32
|
requirements:
|
19
|
-
- - "
|
33
|
+
- - "~>"
|
20
34
|
- !ruby/object:Gem::Version
|
21
|
-
version: '
|
35
|
+
version: '1.16'
|
22
36
|
type: :development
|
23
37
|
prerelease: false
|
24
38
|
version_requirements: !ruby/object:Gem::Requirement
|
25
39
|
requirements:
|
26
|
-
- - "
|
40
|
+
- - "~>"
|
27
41
|
- !ruby/object:Gem::Version
|
28
|
-
version: '
|
42
|
+
version: '1.16'
|
29
43
|
- !ruby/object:Gem::Dependency
|
30
44
|
name: rake
|
31
45
|
requirement: !ruby/object:Gem::Requirement
|
@@ -80,25 +94,34 @@ files:
|
|
80
94
|
- README.md
|
81
95
|
- bin/gherkin
|
82
96
|
- bin/gherkin-ruby
|
83
|
-
-
|
84
|
-
-
|
97
|
+
- gherkin-go/gherkin-go-darwin-386
|
98
|
+
- gherkin-go/gherkin-go-darwin-amd64
|
99
|
+
- gherkin-go/gherkin-go-freebsd-386
|
100
|
+
- gherkin-go/gherkin-go-freebsd-amd64
|
101
|
+
- gherkin-go/gherkin-go-freebsd-arm
|
102
|
+
- gherkin-go/gherkin-go-linux-386
|
103
|
+
- gherkin-go/gherkin-go-linux-amd64
|
104
|
+
- gherkin-go/gherkin-go-linux-arm
|
105
|
+
- gherkin-go/gherkin-go-linux-mips
|
106
|
+
- gherkin-go/gherkin-go-linux-mips64
|
107
|
+
- gherkin-go/gherkin-go-linux-mips64le
|
108
|
+
- gherkin-go/gherkin-go-linux-mipsle
|
109
|
+
- gherkin-go/gherkin-go-linux-s390x
|
110
|
+
- gherkin-go/gherkin-go-netbsd-386
|
111
|
+
- gherkin-go/gherkin-go-netbsd-amd64
|
112
|
+
- gherkin-go/gherkin-go-netbsd-arm
|
113
|
+
- gherkin-go/gherkin-go-openbsd-386
|
114
|
+
- gherkin-go/gherkin-go-openbsd-amd64
|
115
|
+
- gherkin-go/gherkin-go-windows-386.exe
|
116
|
+
- gherkin-go/gherkin-go-windows-amd64.exe
|
85
117
|
- lib/gherkin/dialect.rb
|
86
|
-
- lib/gherkin/
|
87
|
-
- lib/gherkin/gherkin
|
88
|
-
- lib/gherkin/
|
89
|
-
- lib/gherkin/parser.rb
|
90
|
-
- lib/gherkin/pickles/compiler.rb
|
91
|
-
- lib/gherkin/stream/gherkin_events.rb
|
92
|
-
- lib/gherkin/stream/source_events.rb
|
93
|
-
- lib/gherkin/token.rb
|
94
|
-
- lib/gherkin/token_formatter_builder.rb
|
95
|
-
- lib/gherkin/token_matcher.rb
|
96
|
-
- lib/gherkin/token_scanner.rb
|
118
|
+
- lib/gherkin/exe_file_path.rb
|
119
|
+
- lib/gherkin/gherkin.rb
|
120
|
+
- lib/gherkin/protobuf_cucumber_messages.rb
|
97
121
|
- spec/capture_warnings.rb
|
98
122
|
- spec/coverage.rb
|
99
|
-
- spec/gherkin/
|
100
|
-
- spec/gherkin/
|
101
|
-
- spec/gherkin/stream/test_fr.feature
|
123
|
+
- spec/gherkin/dialect_spec.rb
|
124
|
+
- spec/gherkin/gherkin_spec.rb
|
102
125
|
homepage: https://github.com/cucumber/gherkin-ruby
|
103
126
|
licenses:
|
104
127
|
- MIT
|
@@ -120,13 +143,12 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
120
143
|
version: '0'
|
121
144
|
requirements: []
|
122
145
|
rubyforge_project:
|
123
|
-
rubygems_version: 2.7.
|
146
|
+
rubygems_version: 2.7.7
|
124
147
|
signing_key:
|
125
148
|
specification_version: 4
|
126
|
-
summary: gherkin-
|
149
|
+
summary: gherkin-6.0.10
|
127
150
|
test_files:
|
128
|
-
- spec/gherkin/stream/test_fr.feature
|
129
|
-
- spec/gherkin/stream/gherkin_events_spec.rb
|
130
|
-
- spec/gherkin/parser_spec.rb
|
131
151
|
- spec/capture_warnings.rb
|
132
152
|
- spec/coverage.rb
|
153
|
+
- spec/gherkin/dialect_spec.rb
|
154
|
+
- spec/gherkin/gherkin_spec.rb
|
data/lib/gherkin/ast_builder.rb
DELETED
@@ -1,257 +0,0 @@
|
|
1
|
-
require 'gherkin/ast_node'
|
2
|
-
|
3
|
-
module Gherkin
|
4
|
-
class AstBuilder
|
5
|
-
def initialize
|
6
|
-
reset
|
7
|
-
end
|
8
|
-
|
9
|
-
def reset
|
10
|
-
@stack = [AstNode.new(:None)]
|
11
|
-
@comments = []
|
12
|
-
end
|
13
|
-
|
14
|
-
def start_rule(rule_type)
|
15
|
-
@stack.push AstNode.new(rule_type)
|
16
|
-
end
|
17
|
-
|
18
|
-
def end_rule(rule_type)
|
19
|
-
node = @stack.pop
|
20
|
-
current_node.add(node.rule_type, transform_node(node))
|
21
|
-
end
|
22
|
-
|
23
|
-
def build(token)
|
24
|
-
if token.matched_type == :Comment
|
25
|
-
@comments.push({
|
26
|
-
type: :Comment,
|
27
|
-
location: get_location(token),
|
28
|
-
text: token.matched_text
|
29
|
-
})
|
30
|
-
else
|
31
|
-
current_node.add(token.matched_type, token)
|
32
|
-
end
|
33
|
-
end
|
34
|
-
|
35
|
-
def get_result
|
36
|
-
current_node.get_single(:GherkinDocument)
|
37
|
-
end
|
38
|
-
|
39
|
-
def current_node
|
40
|
-
@stack.last
|
41
|
-
end
|
42
|
-
|
43
|
-
def get_location(token, column=nil)
|
44
|
-
# TODO: translated from JS... is it right?
|
45
|
-
(column.nil? || column.zero?) ? token.location : {line: token.location[:line], column: column}
|
46
|
-
end
|
47
|
-
|
48
|
-
def get_tags(node)
|
49
|
-
tags = []
|
50
|
-
tags_node = node.get_single(:Tags)
|
51
|
-
return tags unless tags_node
|
52
|
-
|
53
|
-
tags_node.get_tokens(:TagLine).each do |token|
|
54
|
-
token.matched_items.each do |tag_item|
|
55
|
-
tags.push({
|
56
|
-
type: :Tag,
|
57
|
-
location: get_location(token, tag_item.column),
|
58
|
-
name: tag_item.text
|
59
|
-
})
|
60
|
-
end
|
61
|
-
end
|
62
|
-
|
63
|
-
tags
|
64
|
-
end
|
65
|
-
|
66
|
-
def get_table_rows(node)
|
67
|
-
rows = node.get_tokens(:TableRow).map do |token|
|
68
|
-
{
|
69
|
-
type: :TableRow,
|
70
|
-
location: get_location(token),
|
71
|
-
cells: get_cells(token)
|
72
|
-
}
|
73
|
-
end
|
74
|
-
ensure_cell_count(rows);
|
75
|
-
rows
|
76
|
-
end
|
77
|
-
|
78
|
-
def ensure_cell_count(rows)
|
79
|
-
return if rows.empty?
|
80
|
-
cell_count = rows[0][:cells].length
|
81
|
-
rows.each do |row|
|
82
|
-
if (row[:cells].length != cell_count)
|
83
|
-
raise AstBuilderException.new("inconsistent cell count within the table", row[:location]);
|
84
|
-
end
|
85
|
-
end
|
86
|
-
end
|
87
|
-
|
88
|
-
def get_cells(table_row_token)
|
89
|
-
table_row_token.matched_items.map do |cell_item|
|
90
|
-
{
|
91
|
-
type: :TableCell,
|
92
|
-
location: get_location(table_row_token, cell_item.column),
|
93
|
-
value: cell_item.text
|
94
|
-
}
|
95
|
-
end
|
96
|
-
end
|
97
|
-
|
98
|
-
def get_description(node)
|
99
|
-
node.get_single(:Description)
|
100
|
-
end
|
101
|
-
|
102
|
-
def get_steps(node)
|
103
|
-
node.get_items(:Step)
|
104
|
-
end
|
105
|
-
|
106
|
-
def transform_node(node)
|
107
|
-
case node.rule_type
|
108
|
-
when :Step
|
109
|
-
step_line = node.get_token(:StepLine)
|
110
|
-
step_argument = node.get_single(:DataTable) || node.get_single(:DocString) || nil
|
111
|
-
|
112
|
-
reject_nils(
|
113
|
-
type: node.rule_type,
|
114
|
-
location: get_location(step_line),
|
115
|
-
keyword: step_line.matched_keyword,
|
116
|
-
text: step_line.matched_text,
|
117
|
-
argument: step_argument
|
118
|
-
)
|
119
|
-
when :DocString
|
120
|
-
separator_token = node.get_tokens(:DocStringSeparator)[0]
|
121
|
-
content_type = separator_token.matched_text == '' ? nil : separator_token.matched_text
|
122
|
-
line_tokens = node.get_tokens(:Other)
|
123
|
-
content = line_tokens.map { |t| t.matched_text }.join("\n")
|
124
|
-
|
125
|
-
reject_nils(
|
126
|
-
type: node.rule_type,
|
127
|
-
location: get_location(separator_token),
|
128
|
-
contentType: content_type,
|
129
|
-
content: content
|
130
|
-
)
|
131
|
-
when :DataTable
|
132
|
-
rows = get_table_rows(node)
|
133
|
-
reject_nils(
|
134
|
-
type: node.rule_type,
|
135
|
-
location: rows[0][:location],
|
136
|
-
rows: rows,
|
137
|
-
)
|
138
|
-
when :Background
|
139
|
-
background_line = node.get_token(:BackgroundLine)
|
140
|
-
description = get_description(node)
|
141
|
-
steps = get_steps(node)
|
142
|
-
|
143
|
-
reject_nils(
|
144
|
-
type: node.rule_type,
|
145
|
-
location: get_location(background_line),
|
146
|
-
keyword: background_line.matched_keyword,
|
147
|
-
name: background_line.matched_text,
|
148
|
-
description: description,
|
149
|
-
steps: steps
|
150
|
-
)
|
151
|
-
when :Scenario_Definition
|
152
|
-
tags = get_tags(node)
|
153
|
-
scenario_node = node.get_single(:Scenario)
|
154
|
-
if(scenario_node)
|
155
|
-
scenario_line = scenario_node.get_token(:ScenarioLine)
|
156
|
-
description = get_description(scenario_node)
|
157
|
-
steps = get_steps(scenario_node)
|
158
|
-
|
159
|
-
reject_nils(
|
160
|
-
type: scenario_node.rule_type,
|
161
|
-
tags: tags,
|
162
|
-
location: get_location(scenario_line),
|
163
|
-
keyword: scenario_line.matched_keyword,
|
164
|
-
name: scenario_line.matched_text,
|
165
|
-
description: description,
|
166
|
-
steps: steps
|
167
|
-
)
|
168
|
-
else
|
169
|
-
scenario_outline_node = node.get_single(:ScenarioOutline)
|
170
|
-
raise 'Internal grammar error' unless scenario_outline_node
|
171
|
-
|
172
|
-
scenario_outline_line = scenario_outline_node.get_token(:ScenarioOutlineLine)
|
173
|
-
description = get_description(scenario_outline_node)
|
174
|
-
steps = get_steps(scenario_outline_node)
|
175
|
-
examples = scenario_outline_node.get_items(:Examples_Definition)
|
176
|
-
|
177
|
-
reject_nils(
|
178
|
-
type: scenario_outline_node.rule_type,
|
179
|
-
tags: tags,
|
180
|
-
location: get_location(scenario_outline_line),
|
181
|
-
keyword: scenario_outline_line.matched_keyword,
|
182
|
-
name: scenario_outline_line.matched_text,
|
183
|
-
description: description,
|
184
|
-
steps: steps,
|
185
|
-
examples: examples
|
186
|
-
)
|
187
|
-
end
|
188
|
-
when :Examples_Definition
|
189
|
-
tags = get_tags(node)
|
190
|
-
examples_node = node.get_single(:Examples)
|
191
|
-
examples_line = examples_node.get_token(:ExamplesLine)
|
192
|
-
description = get_description(examples_node)
|
193
|
-
examples_table = examples_node.get_single(:Examples_Table)
|
194
|
-
|
195
|
-
reject_nils(
|
196
|
-
type: examples_node.rule_type,
|
197
|
-
tags: tags,
|
198
|
-
location: get_location(examples_line),
|
199
|
-
keyword: examples_line.matched_keyword,
|
200
|
-
name: examples_line.matched_text,
|
201
|
-
description: description,
|
202
|
-
tableHeader: !examples_table.nil? ? examples_table[:tableHeader] : nil,
|
203
|
-
tableBody: !examples_table.nil? ? examples_table[:tableBody] : nil
|
204
|
-
)
|
205
|
-
when :Examples_Table
|
206
|
-
rows = get_table_rows(node)
|
207
|
-
|
208
|
-
reject_nils(
|
209
|
-
tableHeader: rows.first,
|
210
|
-
tableBody: rows[1..-1]
|
211
|
-
)
|
212
|
-
when :Description
|
213
|
-
line_tokens = node.get_tokens(:Other)
|
214
|
-
# Trim trailing empty lines
|
215
|
-
last_non_empty = line_tokens.rindex { |token| !token.line.trimmed_line_text.empty? }
|
216
|
-
description = line_tokens[0..last_non_empty].map { |token| token.matched_text }.join("\n")
|
217
|
-
return description
|
218
|
-
when :Feature
|
219
|
-
header = node.get_single(:Feature_Header)
|
220
|
-
return unless header
|
221
|
-
tags = get_tags(header)
|
222
|
-
feature_line = header.get_token(:FeatureLine)
|
223
|
-
return unless feature_line
|
224
|
-
children = []
|
225
|
-
background = node.get_single(:Background)
|
226
|
-
children.push(background) if background
|
227
|
-
children.concat(node.get_items(:Scenario_Definition))
|
228
|
-
description = get_description(header)
|
229
|
-
language = feature_line.matched_gherkin_dialect
|
230
|
-
|
231
|
-
reject_nils(
|
232
|
-
type: node.rule_type,
|
233
|
-
tags: tags,
|
234
|
-
location: get_location(feature_line),
|
235
|
-
language: language,
|
236
|
-
keyword: feature_line.matched_keyword,
|
237
|
-
name: feature_line.matched_text,
|
238
|
-
description: description,
|
239
|
-
children: children,
|
240
|
-
)
|
241
|
-
when :GherkinDocument
|
242
|
-
feature = node.get_single(:Feature)
|
243
|
-
reject_nils(
|
244
|
-
type: node.rule_type,
|
245
|
-
feature: feature,
|
246
|
-
comments: @comments
|
247
|
-
)
|
248
|
-
else
|
249
|
-
return node
|
250
|
-
end
|
251
|
-
end
|
252
|
-
|
253
|
-
def reject_nils(values)
|
254
|
-
values.reject { |k,v| v.nil? }
|
255
|
-
end
|
256
|
-
end
|
257
|
-
end
|
data/lib/gherkin/ast_node.rb
DELETED
@@ -1,30 +0,0 @@
|
|
1
|
-
module Gherkin
|
2
|
-
class AstNode
|
3
|
-
attr_reader :rule_type
|
4
|
-
|
5
|
-
def initialize(rule_type)
|
6
|
-
@rule_type = rule_type
|
7
|
-
@_sub_items = Hash.new { |hash, key| hash[key] = [] } # returns [] for unknown key
|
8
|
-
end
|
9
|
-
|
10
|
-
def add(rule_type, obj)
|
11
|
-
@_sub_items[rule_type].push(obj)
|
12
|
-
end
|
13
|
-
|
14
|
-
def get_single(rule_type)
|
15
|
-
@_sub_items[rule_type].first
|
16
|
-
end
|
17
|
-
|
18
|
-
def get_items(rule_type)
|
19
|
-
@_sub_items[rule_type]
|
20
|
-
end
|
21
|
-
|
22
|
-
def get_token(token_type)
|
23
|
-
get_single(token_type)
|
24
|
-
end
|
25
|
-
|
26
|
-
def get_tokens(token_type)
|
27
|
-
@_sub_items[token_type]
|
28
|
-
end
|
29
|
-
end
|
30
|
-
end
|
data/lib/gherkin/errors.rb
DELETED
@@ -1,45 +0,0 @@
|
|
1
|
-
module Gherkin
|
2
|
-
class ParserError < StandardError; end
|
3
|
-
|
4
|
-
class ParserException < ParserError
|
5
|
-
attr_reader :location
|
6
|
-
|
7
|
-
def initialize(message, location)
|
8
|
-
@location = location
|
9
|
-
super("(#{location[:line]}:#{location[:column] || 0}): #{message}")
|
10
|
-
end
|
11
|
-
end
|
12
|
-
|
13
|
-
class NoSuchLanguageException < ParserException
|
14
|
-
def initialize(language, location)
|
15
|
-
super "Language not supported: #{language}", location
|
16
|
-
end
|
17
|
-
end
|
18
|
-
|
19
|
-
class AstBuilderException < ParserException; end
|
20
|
-
|
21
|
-
class CompositeParserException < ParserError
|
22
|
-
attr_reader :errors
|
23
|
-
|
24
|
-
def initialize(errors)
|
25
|
-
@errors = errors
|
26
|
-
super "Parser errors:\n" + errors.map(&:message).join("\n")
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
30
|
-
class UnexpectedTokenException < ParserException
|
31
|
-
def initialize(received_token, expected_token_types, state_comment)
|
32
|
-
message = "expected: #{expected_token_types.join(", ")}, got '#{received_token.token_value.strip}'"
|
33
|
-
column = received_token.location[:column]
|
34
|
-
location = (column.nil? || column.zero?) ? {line: received_token.location[:line], column: received_token.line.indent + 1} : received_token.location
|
35
|
-
super(message, location)
|
36
|
-
end
|
37
|
-
end
|
38
|
-
|
39
|
-
class UnexpectedEOFException < ParserException
|
40
|
-
def initialize(received_token, expected_token_types, state_comment)
|
41
|
-
message = "unexpected end of file, expected: #{expected_token_types.join(", ")}"
|
42
|
-
super(message, received_token.location)
|
43
|
-
end
|
44
|
-
end
|
45
|
-
end
|