gherkin 7.0.4 → 8.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.
Files changed (43) hide show
  1. checksums.yaml +4 -4
  2. data/bin/gherkin +34 -12
  3. data/lib/gherkin.rb +42 -0
  4. data/lib/gherkin/ast_builder.rb +260 -0
  5. data/lib/gherkin/ast_node.rb +30 -0
  6. data/lib/gherkin/dialect.rb +2 -12
  7. data/lib/gherkin/errors.rb +45 -0
  8. data/lib/gherkin/gherkin-languages.json +3520 -0
  9. data/lib/gherkin/gherkin_line.rb +97 -0
  10. data/lib/gherkin/parser.rb +3429 -0
  11. data/lib/gherkin/pickles/compiler.rb +233 -0
  12. data/lib/gherkin/stream/parser_message_stream.rb +93 -0
  13. data/lib/gherkin/stream/protobuf_message_stream.rb +21 -0
  14. data/lib/gherkin/stream/subprocess_message_stream.rb +26 -0
  15. data/lib/gherkin/token.rb +18 -0
  16. data/lib/gherkin/token_formatter_builder.rb +39 -0
  17. data/lib/gherkin/token_matcher.rb +169 -0
  18. data/lib/gherkin/token_scanner.rb +40 -0
  19. data/spec/gherkin/gherkin_spec.rb +36 -345
  20. data/spec/gherkin/stream/subprocess_message_stream_spec.rb +18 -0
  21. metadata +28 -53
  22. data/executables/gherkin-darwin-386 +0 -0
  23. data/executables/gherkin-darwin-amd64 +0 -0
  24. data/executables/gherkin-freebsd-386 +0 -0
  25. data/executables/gherkin-freebsd-amd64 +0 -0
  26. data/executables/gherkin-freebsd-arm +0 -0
  27. data/executables/gherkin-linux-386 +0 -0
  28. data/executables/gherkin-linux-amd64 +0 -0
  29. data/executables/gherkin-linux-arm +0 -0
  30. data/executables/gherkin-linux-mips +0 -0
  31. data/executables/gherkin-linux-mips64 +0 -0
  32. data/executables/gherkin-linux-mips64le +0 -0
  33. data/executables/gherkin-linux-mipsle +0 -0
  34. data/executables/gherkin-linux-s390x +0 -0
  35. data/executables/gherkin-netbsd-386 +0 -0
  36. data/executables/gherkin-netbsd-amd64 +0 -0
  37. data/executables/gherkin-netbsd-arm +0 -0
  38. data/executables/gherkin-openbsd-386 +0 -0
  39. data/executables/gherkin-openbsd-amd64 +0 -0
  40. data/executables/gherkin-windows-386.exe +0 -0
  41. data/executables/gherkin-windows-amd64.exe +0 -0
  42. data/lib/gherkin/exe_file_path.rb +0 -3
  43. data/lib/gherkin/gherkin.rb +0 -72
@@ -0,0 +1,40 @@
1
+ require 'stringio'
2
+ require 'gherkin/token'
3
+ require 'gherkin/gherkin_line'
4
+
5
+ module Gherkin
6
+ # The scanner reads a gherkin doc (typically read from a .feature file) and
7
+ # creates a token for line. The tokens are passed to the parser, which outputs
8
+ # an AST (Abstract Syntax Tree).
9
+ #
10
+ # If the scanner sees a # language header, it will reconfigure itself dynamically
11
+ # to look for Gherkin keywords for the associated language. The keywords are defined
12
+ # in gherkin-languages.json.
13
+ class TokenScanner
14
+ def initialize(source_or_io)
15
+ @line_number = 0
16
+
17
+ case(source_or_io)
18
+ when String
19
+ @io = StringIO.new(source_or_io)
20
+ when StringIO, IO
21
+ @io = source_or_io
22
+ else
23
+ fail ArgumentError, "Please a pass String, StringIO or IO. I got a #{source_or_io.class}"
24
+ end
25
+ end
26
+
27
+ def read
28
+ location = {line: @line_number += 1, column: 0}
29
+ if @io.nil? || line = @io.gets
30
+ gherkin_line = line ? GherkinLine.new(line, location[:line]) : nil
31
+ Token.new(gherkin_line, location)
32
+ else
33
+ @io.close unless @io.closed? # ARGF closes the last file after final gets
34
+ @io = nil
35
+ Token.new(nil, location)
36
+ end
37
+ end
38
+
39
+ end
40
+ end
@@ -1,354 +1,45 @@
1
- # coding: utf-8
2
1
  require 'rspec'
3
- require 'gherkin/gherkin'
4
-
5
- module Gherkin
6
- describe Gherkin do
7
- context 'using paths' do
8
- it "works" do
9
- messages = Gherkin.from_paths(
10
- ["testdata/good/minimal.feature"]
11
- )
12
- expect(messages.to_a.length).to eq(3)
13
- end
14
- end
15
-
16
- context 'using string content' do
17
- it 'works' do
18
- file = File.new('testdata/good/minimal.feature')
19
- content = file.read.encode('UTF-8')
20
- messages = Gherkin.from_source('testdata/good/minimal.feature', content).to_a
21
- expect(messages.to_a.length).to eq(3)
22
- end
23
-
24
- it 'also works' do
25
- content = """
26
- Feature:
27
-
28
- Scenario: scenario 1
29
- Given text
30
-
31
- Scenario: scenario 2
32
- Given text
33
-
34
- Scenario: scenario 3
35
- Given text
36
-
37
- Scenario: scenario 4
38
- Given text
39
-
40
- Scenario: scenario 5
41
- Given text
42
-
43
- Scenario: scenario 6
44
- Given text
45
-
46
- Scenario: scenario 7
47
- Given text
48
-
49
- Scenario: scenario 8
50
- Given text
51
-
52
- Scenario: scenario 9
53
- Given text
54
-
55
- Scenario: scenario 10
56
- Given text
57
-
58
- Scenario: scenario 11
59
- Given text
60
-
61
- Scenario: scenario 12
62
- Given text
63
-
64
- Scenario: scenario 13
65
- Given text
66
-
67
- Scenario: scenario 14
68
- Given text
69
-
70
- Scenario: scenario 15
71
- Given text
72
-
73
- Scenario: scenario 16
74
- Given text
75
-
76
- Scenario: scenario 17
77
- Given text
78
-
79
- Scenario: scenario 18
80
- Given text
81
-
82
- Scenario: scenario 19
83
- Given text
84
-
85
- Scenario: scenario 20
86
- Given text
87
-
88
- Scenario: scenario 21
89
- Given text
90
-
91
- Scenario: scenario 22
92
- Given text
93
-
94
- Scenario: scenario 23
95
- Given text
96
-
97
- Scenario: scenario 24
98
- Given text
99
-
100
- Scenario: scenario 25
101
- Given text
102
-
103
- Scenario: scenario 26
104
- Given text
105
-
106
- Scenario: scenario 27
107
- Given text
108
-
109
- Scenario: scenario 28
110
- Given text
111
-
112
- Scenario: scenario 29
113
- Given text
114
-
115
- Scenario: scenario 30
116
- Given text
117
-
118
- Scenario: scenario 31
119
- Given text
120
-
121
- Scenario: scenario 32
122
- Given text
123
-
124
- Scenario: scenario 33
125
- Given text
126
-
127
- Scenario: scenario 34
128
- Given text
129
-
130
- Scenario: scenario 35
131
- Given text
132
-
133
- Scenario: scenario 36
134
- Given text
135
-
136
- Scenario: scenario 37
137
- Given text
138
-
139
- Scenario: scenario 38
140
- Given text
141
-
142
- Scenario: scenario 39
143
- Given text
144
-
145
- Scenario: scenario 40
146
- Given text
147
-
148
- Scenario: scenario 41
149
- Given text
150
-
151
- Scenario: scenario 42
152
- Given text
153
-
154
- Scenario: scenario 43
155
- Given text
156
-
157
- Scenario: scenario 44
158
- Given text
159
-
160
- Scenario: scenario 45
161
- Given text
162
-
163
- Scenario: scenario 46
164
- Given text
165
-
166
- Scenario: scenario 47
167
- Given text
168
-
169
- Scenario: scenario 48
170
- Given text
171
-
172
- Scenario: scenario 49
173
- Given text
174
- """
175
- messages = Gherkin.from_source('dummy', content).to_a
176
- expect(messages.to_a.length).to eq(51)
177
- end
178
-
179
- it 'still works' do
180
- content = """
181
- Feature:
182
-
183
- Scenario: scenario 1
184
- Given text
185
-
186
- Scenario: scenario 2
187
- Given text
188
-
189
- Scenario: scenario 3
190
- Given text
191
-
192
- Scenario: scenario 4
193
- Given text
194
-
195
- Scenario: scenario 5
196
- Given text
197
-
198
- Scenario: scenario 6
199
- Given text
200
-
201
- Scenario: scenario 7
202
- Given text
203
-
204
- Scenario: scenario 8
205
- Given text
206
-
207
- Scenario: scenario 9
208
- Given text
209
-
210
- Scenario: scenario 10
211
- Given text
212
-
213
- Scenario: scenario 11
214
- Given text
215
-
216
- Scenario: scenario 12
217
- Given text
218
-
219
- Scenario: scenario 13
220
- Given text
221
-
222
- Scenario: scenario 14
223
- Given text
224
-
225
- Scenario: scenario 15
226
- Given text
227
-
228
- Scenario: scenario 16
229
- Given text
230
-
231
- Scenario: scenario 17
232
- Given text
233
-
234
- Scenario: scenario 18
235
- Given text
236
-
237
- Scenario: scenario 19
238
- Given text
239
-
240
- Scenario: scenario 20
241
- Given text
242
-
243
- Scenario: scenario 21
244
- Given text
245
-
246
- Scenario: scenario 22
247
- Given text
248
-
249
- Scenario: scenario 23
250
- Given text
251
-
252
- Scenario: scenario 24
253
- Given text
254
-
255
- Scenario: scenario 25
256
- Given text
257
-
258
- Scenario: scenario 26
259
- Given text
260
-
261
- Scenario: scenario 27
262
- Given text
263
-
264
- Scenario: scenario 28
265
- Given text
266
-
267
- Scenario: scenario 29
268
- Given text
269
-
270
- Scenario: scenario 30
271
- Given text
272
-
273
- Scenario: scenario 31
274
- Given text
275
-
276
- Scenario: scenario 32
277
- Given text
278
-
279
- Scenario: scenario 33
280
- Given text
281
-
282
- Scenario: scenario 34
283
- Given text
284
-
285
- Scenario: scenario 35
286
- Given text
287
-
288
- Scenario: scenario 36
289
- Given text
290
-
291
- Scenario: scenario 37
292
- Given text
293
-
294
- Scenario: scenario 38
295
- Given text
296
-
297
- Scenario: scenario 39
298
- Given text
299
-
300
- Scenario: scenario 40
301
- Given text
302
-
303
- Scenario: scenario 41
304
- Given text
305
-
306
- Scenario: scenario 42
307
- Given text
308
-
309
- Scenario: scenario 43
310
- Given text
311
-
312
- Scenario: scenario 44
313
- Given text
314
-
315
- Scenario: scenario 45
316
- Given text
317
-
318
- Scenario: scenario 46
319
- Given text
320
-
321
- Scenario: scenario 47
322
- Given text
2
+ require 'gherkin'
3
+
4
+ describe Gherkin do
5
+ it "can process feature file paths" do
6
+ messages = Gherkin.from_paths(
7
+ ["testdata/good/minimal.feature"],
8
+ {include_source: true,
9
+ include_gherkin_document: true,
10
+ include_pickles: true}
11
+ ).to_a
12
+
13
+ expect(messages.length).to eq(3)
14
+ end
323
15
 
324
- Scenario: scenario 48
325
- Given text
16
+ it "can process feature file content" do
17
+ data = File.open("testdata/good/minimal.feature", 'r:UTF-8', &:read)
326
18
 
327
- Scenario: scenario 49
328
- Given text
19
+ messages = Gherkin.from_source(
20
+ "uri",
21
+ data,
22
+ {include_source: true,
23
+ include_gherkin_document: true,
24
+ include_pickles: true}
25
+ ).to_a
329
26
 
330
- Scenario: scenario 50
331
- Given text
332
- """
333
- messages = Gherkin.from_source('dummy', content).to_a
334
- expect(messages.to_a.length).to eq(52)
335
- end
27
+ expect(messages.length).to eq(3)
28
+ end
336
29
 
337
- end
30
+ it "can set the default dialect for the feature file content" do
31
+ data = File.open("testdata/good/i18n_no.feature", 'r:UTF-8', &:read)
32
+ data_without_language_header = data.split("\n")[1..-1].join("\n")
338
33
 
339
- context 'setting the default dialect' do
340
- it 'features will be parsed using the set default dialect' do
341
- content = """
342
- Egenskap: i18n support
34
+ messages = Gherkin.from_source(
35
+ "uri",
36
+ data,
37
+ {include_source: true,
38
+ include_gherkin_document: true,
39
+ include_pickles: true,
40
+ default_dialect: "no"}
41
+ ).to_a
343
42
 
344
- Scenario: Parsing many languages
345
- Gitt Gherkin supports many languages
346
- Når Norwegian keywords are parsed
347
- Så they should be recognized
348
- """
349
- messages = Gherkin.from_source('dummy', content, {default_dialect: 'no'})
350
- expect(messages.to_a.length).to eq(3)
351
- end
352
- end
43
+ expect(messages.length).to eq(3)
353
44
  end
354
45
  end
@@ -0,0 +1,18 @@
1
+ require 'rspec'
2
+ require 'gherkin/stream/subprocess_message_stream'
3
+
4
+ module Gherkin
5
+ module Stream
6
+ describe SubprocessMessageStream do
7
+ it "works" do
8
+ cucumber_messages = SubprocessMessageStream.new(
9
+ "./bin/gherkin",
10
+ ["testdata/good/minimal.feature"],
11
+ true, true, true
12
+ )
13
+ messages = cucumber_messages.messages.to_a
14
+ expect(messages.length).to eq(3)
15
+ end
16
+ end
17
+ end
18
+ end
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: 7.0.4
4
+ version: 8.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gáspár Nagy
@@ -10,68 +10,48 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2019-08-29 00:00:00.000000000 Z
13
+ date: 2019-10-03 00:00:00.000000000 Z
14
14
  dependencies:
15
- - !ruby/object:Gem::Dependency
16
- name: c21e
17
- requirement: !ruby/object:Gem::Requirement
18
- requirements:
19
- - - "~>"
20
- - !ruby/object:Gem::Version
21
- version: '2.0'
22
- - - ">="
23
- - !ruby/object:Gem::Version
24
- version: 2.0.0
25
- type: :runtime
26
- prerelease: false
27
- version_requirements: !ruby/object:Gem::Requirement
28
- requirements:
29
- - - "~>"
30
- - !ruby/object:Gem::Version
31
- version: '2.0'
32
- - - ">="
33
- - !ruby/object:Gem::Version
34
- version: 2.0.0
35
15
  - !ruby/object:Gem::Dependency
36
16
  name: cucumber-messages
37
17
  requirement: !ruby/object:Gem::Requirement
38
18
  requirements:
39
19
  - - "~>"
40
20
  - !ruby/object:Gem::Version
41
- version: '5.0'
21
+ version: '6.0'
42
22
  - - ">="
43
23
  - !ruby/object:Gem::Version
44
- version: 5.0.1
24
+ version: 6.0.1
45
25
  type: :runtime
46
26
  prerelease: false
47
27
  version_requirements: !ruby/object:Gem::Requirement
48
28
  requirements:
49
29
  - - "~>"
50
30
  - !ruby/object:Gem::Version
51
- version: '5.0'
31
+ version: '6.0'
52
32
  - - ">="
53
33
  - !ruby/object:Gem::Version
54
- version: 5.0.1
34
+ version: 6.0.1
55
35
  - !ruby/object:Gem::Dependency
56
36
  name: rake
57
37
  requirement: !ruby/object:Gem::Requirement
58
38
  requirements:
59
39
  - - "~>"
60
40
  - !ruby/object:Gem::Version
61
- version: '12.3'
41
+ version: '13.0'
62
42
  - - ">="
63
43
  - !ruby/object:Gem::Version
64
- version: 12.3.3
44
+ version: 13.0.0
65
45
  type: :development
66
46
  prerelease: false
67
47
  version_requirements: !ruby/object:Gem::Requirement
68
48
  requirements:
69
49
  - - "~>"
70
50
  - !ruby/object:Gem::Version
71
- version: '12.3'
51
+ version: '13.0'
72
52
  - - ">="
73
53
  - !ruby/object:Gem::Version
74
- version: 12.3.3
54
+ version: 13.0.0
75
55
  - !ruby/object:Gem::Dependency
76
56
  name: rspec
77
57
  requirement: !ruby/object:Gem::Requirement
@@ -124,33 +104,27 @@ files:
124
104
  - README.md
125
105
  - bin/gherkin
126
106
  - bin/gherkin-ruby
127
- - executables/gherkin-darwin-386
128
- - executables/gherkin-darwin-amd64
129
- - executables/gherkin-freebsd-386
130
- - executables/gherkin-freebsd-amd64
131
- - executables/gherkin-freebsd-arm
132
- - executables/gherkin-linux-386
133
- - executables/gherkin-linux-amd64
134
- - executables/gherkin-linux-arm
135
- - executables/gherkin-linux-mips
136
- - executables/gherkin-linux-mips64
137
- - executables/gherkin-linux-mips64le
138
- - executables/gherkin-linux-mipsle
139
- - executables/gherkin-linux-s390x
140
- - executables/gherkin-netbsd-386
141
- - executables/gherkin-netbsd-amd64
142
- - executables/gherkin-netbsd-arm
143
- - executables/gherkin-openbsd-386
144
- - executables/gherkin-openbsd-amd64
145
- - executables/gherkin-windows-386.exe
146
- - executables/gherkin-windows-amd64.exe
107
+ - lib/gherkin.rb
108
+ - lib/gherkin/ast_builder.rb
109
+ - lib/gherkin/ast_node.rb
147
110
  - lib/gherkin/dialect.rb
148
- - lib/gherkin/exe_file_path.rb
149
- - lib/gherkin/gherkin.rb
111
+ - lib/gherkin/errors.rb
112
+ - lib/gherkin/gherkin-languages.json
113
+ - lib/gherkin/gherkin_line.rb
114
+ - lib/gherkin/parser.rb
115
+ - lib/gherkin/pickles/compiler.rb
116
+ - lib/gherkin/stream/parser_message_stream.rb
117
+ - lib/gherkin/stream/protobuf_message_stream.rb
118
+ - lib/gherkin/stream/subprocess_message_stream.rb
119
+ - lib/gherkin/token.rb
120
+ - lib/gherkin/token_formatter_builder.rb
121
+ - lib/gherkin/token_matcher.rb
122
+ - lib/gherkin/token_scanner.rb
150
123
  - spec/capture_warnings.rb
151
124
  - spec/coverage.rb
152
125
  - spec/gherkin/dialect_spec.rb
153
126
  - spec/gherkin/gherkin_spec.rb
127
+ - spec/gherkin/stream/subprocess_message_stream_spec.rb
154
128
  homepage: https://github.com/cucumber/gherkin-ruby
155
129
  licenses:
156
130
  - MIT
@@ -180,9 +154,10 @@ rubyforge_project:
180
154
  rubygems_version: 2.7.6.2
181
155
  signing_key:
182
156
  specification_version: 4
183
- summary: gherkin-7.0.4
157
+ summary: gherkin-8.0.0
184
158
  test_files:
185
159
  - spec/gherkin/dialect_spec.rb
160
+ - spec/gherkin/stream/subprocess_message_stream_spec.rb
186
161
  - spec/gherkin/gherkin_spec.rb
187
162
  - spec/capture_warnings.rb
188
163
  - spec/coverage.rb