gherkin 8.2.1 → 9.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/gherkin +9 -26
- data/lib/gherkin/ast_builder.rb +1 -2
- data/lib/gherkin/pickles/compiler.rb +7 -10
- data/lib/gherkin/stream/parser_message_stream.rb +5 -6
- data/lib/gherkin/stream/subprocess_message_stream.rb +1 -1
- metadata +7 -10
- data/lib/gherkin/id_generator.rb +0 -22
- data/spec/gherkin/id_generator_spec.rb +0 -29
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9fed72d45d24c5932634aa88d0b4fc260d407989b45875e340e28f21eab073a1
|
4
|
+
data.tar.gz: 9494dc078667ebba46fa354eba291d8fa2437ea1e68954835190d9989d2950eb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c97ce1a4436c38a6bfc214f62595e93d809013ea7ab99698b9adb43907635385a01b68e12c5c077242ec74abfef00503a6b5f0e82bff34267d220eccac7d910f
|
7
|
+
data.tar.gz: 928daf1069cc5bfeaa8b1c14a11fa273c4b9d366402cbed9e8daa2502a50a9cc412a0255554588733f17bef00aa6a1d31ffbd4855aa76b74b4ab4d725d7f388b
|
data/bin/gherkin
CHANGED
@@ -12,7 +12,7 @@ options = {
|
|
12
12
|
include_source: true,
|
13
13
|
include_gherkin_document: true,
|
14
14
|
include_pickles: true,
|
15
|
-
|
15
|
+
format: 'protobuf',
|
16
16
|
predictable_ids: false
|
17
17
|
}
|
18
18
|
|
@@ -26,8 +26,8 @@ OptionParser.new do |opts|
|
|
26
26
|
opts.on("--[no-]pickles", "Don't print pickle messages") do |v|
|
27
27
|
options[:include_pickles] = v
|
28
28
|
end
|
29
|
-
opts.on("--
|
30
|
-
options[:
|
29
|
+
opts.on("--format ndjson|protobuf", "Output format") do |v|
|
30
|
+
options[:format] = v
|
31
31
|
end
|
32
32
|
opts.on("--predictable-ids", "Generate incrementing ids rather than UUIDs") do |v|
|
33
33
|
options[:predictable_ids] = v
|
@@ -36,29 +36,12 @@ end.parse!
|
|
36
36
|
|
37
37
|
def process_messages(messages, options)
|
38
38
|
messages.each do |message|
|
39
|
-
if options[:
|
40
|
-
|
41
|
-
|
42
|
-
remove_empties(ob)
|
43
|
-
puts JSON.generate(ob)
|
44
|
-
else
|
39
|
+
if options[:format] == 'ndjson'
|
40
|
+
message.write_ndjson_to(STDOUT)
|
41
|
+
elsif options[:format] == 'protobuf'
|
45
42
|
message.write_delimited_to(STDOUT)
|
46
|
-
|
47
|
-
|
48
|
-
end
|
49
|
-
|
50
|
-
def remove_empties(ob)
|
51
|
-
if Hash === ob
|
52
|
-
ob.each do |key, value|
|
53
|
-
if value == []
|
54
|
-
ob.delete(key)
|
55
|
-
else
|
56
|
-
remove_empties(value)
|
57
|
-
end
|
58
|
-
end
|
59
|
-
elsif Array === ob
|
60
|
-
ob.each do |value|
|
61
|
-
remove_empties(value)
|
43
|
+
else
|
44
|
+
raise "Unsupported format: #{options[:format]}"
|
62
45
|
end
|
63
46
|
end
|
64
47
|
end
|
@@ -66,7 +49,7 @@ end
|
|
66
49
|
gherkin_executable = ENV['GHERKIN_EXECUTABLE']
|
67
50
|
if ARGV.empty?
|
68
51
|
# Read protobuf from STDIN
|
69
|
-
messages = Cucumber::Messages::
|
52
|
+
messages = Cucumber::Messages::BinaryToMessageEnumerator.new(STDIN)
|
70
53
|
elsif gherkin_executable
|
71
54
|
# Read protobuf from STDIN
|
72
55
|
messages = Gherkin::Stream::SubprocessMessageStream.new(
|
data/lib/gherkin/ast_builder.rb
CHANGED
@@ -1,10 +1,9 @@
|
|
1
1
|
require 'cucumber/messages'
|
2
2
|
require 'gherkin/ast_node'
|
3
|
-
require 'gherkin/id_generator'
|
4
3
|
|
5
4
|
module Gherkin
|
6
5
|
class AstBuilder
|
7
|
-
def initialize(id_generator
|
6
|
+
def initialize(id_generator)
|
8
7
|
@id_generator = id_generator
|
9
8
|
reset
|
10
9
|
end
|
@@ -1,10 +1,7 @@
|
|
1
|
-
require 'cucumber/messages'
|
2
|
-
require 'gherkin/id_generator'
|
3
|
-
|
4
1
|
module Gherkin
|
5
2
|
module Pickles
|
6
3
|
class Compiler
|
7
|
-
def initialize(id_generator
|
4
|
+
def initialize(id_generator)
|
8
5
|
@id_generator = id_generator
|
9
6
|
end
|
10
7
|
|
@@ -71,7 +68,7 @@ module Gherkin
|
|
71
68
|
tags: pickle_tags(tags),
|
72
69
|
name: scenario.name,
|
73
70
|
language: language,
|
74
|
-
|
71
|
+
ast_node_ids: [scenario.id],
|
75
72
|
steps: steps
|
76
73
|
)
|
77
74
|
pickles.push(pickle)
|
@@ -97,7 +94,7 @@ module Gherkin
|
|
97
94
|
language: language,
|
98
95
|
steps: steps,
|
99
96
|
tags: pickle_tags(tags),
|
100
|
-
|
97
|
+
ast_node_ids: [
|
101
98
|
scenario.id,
|
102
99
|
values_row.id
|
103
100
|
],
|
@@ -130,11 +127,11 @@ module Gherkin
|
|
130
127
|
value_cells = values_row ? values_row.cells : []
|
131
128
|
props = {
|
132
129
|
id: @id_generator.new_id,
|
133
|
-
|
130
|
+
ast_node_ids: [step.id],
|
134
131
|
text: interpolate(step.text, variable_cells, value_cells),
|
135
132
|
}
|
136
133
|
if values_row
|
137
|
-
props[:
|
134
|
+
props[:ast_node_ids].push(values_row.id)
|
138
135
|
end
|
139
136
|
|
140
137
|
if step.data_table
|
@@ -171,7 +168,7 @@ module Gherkin
|
|
171
168
|
content: interpolate(doc_string.content, variable_cells, value_cells)
|
172
169
|
}
|
173
170
|
if doc_string.content_type
|
174
|
-
props[:
|
171
|
+
props[:content_type] = interpolate(doc_string.content_type, variable_cells, value_cells)
|
175
172
|
end
|
176
173
|
Cucumber::Messages::PickleStepArgument::PickleDocString.new(props)
|
177
174
|
end
|
@@ -183,7 +180,7 @@ module Gherkin
|
|
183
180
|
def pickle_tag(tag)
|
184
181
|
Cucumber::Messages::Pickle::PickleTag.new(
|
185
182
|
name: tag.name,
|
186
|
-
|
183
|
+
ast_node_id: tag.id
|
187
184
|
)
|
188
185
|
end
|
189
186
|
end
|
@@ -2,7 +2,6 @@ require 'cucumber/messages'
|
|
2
2
|
require 'gherkin/parser'
|
3
3
|
require 'gherkin/token_matcher'
|
4
4
|
require 'gherkin/pickles/compiler'
|
5
|
-
require 'gherkin/id_generator'
|
6
5
|
|
7
6
|
module Gherkin
|
8
7
|
module Stream
|
@@ -17,10 +16,6 @@ module Gherkin
|
|
17
16
|
@compiler = Pickles::Compiler.new(id_generator)
|
18
17
|
end
|
19
18
|
|
20
|
-
def id_generator_class
|
21
|
-
@options[:predictable_ids] ? Gherkin::IdGenerator::Incrementing : Gherkin::IdGenerator::UUID
|
22
|
-
end
|
23
|
-
|
24
19
|
def messages
|
25
20
|
Enumerator.new do |y|
|
26
21
|
sources.each do |source|
|
@@ -30,7 +25,7 @@ module Gherkin
|
|
30
25
|
|
31
26
|
if @options[:include_gherkin_document]
|
32
27
|
gherkin_document = build_gherkin_document(source)
|
33
|
-
y.yield(Cucumber::Messages::Envelope.new(
|
28
|
+
y.yield(Cucumber::Messages::Envelope.new(gherkin_document: gherkin_document))
|
34
29
|
end
|
35
30
|
if @options[:include_pickles]
|
36
31
|
gherkin_document ||= build_gherkin_document(source)
|
@@ -50,6 +45,10 @@ module Gherkin
|
|
50
45
|
|
51
46
|
private
|
52
47
|
|
48
|
+
def id_generator_class
|
49
|
+
@options[:predictable_ids] ? Cucumber::Messages::IdGenerator::Incrementing : Cucumber::Messages::IdGenerator::UUID
|
50
|
+
end
|
51
|
+
|
53
52
|
def yield_error_attachments(y, errors, uri)
|
54
53
|
errors.each do |err|
|
55
54
|
attachment = Cucumber::Messages::Attachment.new(
|
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: 9.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: 2019-
|
13
|
+
date: 2019-12-10 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: cucumber-messages
|
@@ -18,20 +18,20 @@ dependencies:
|
|
18
18
|
requirements:
|
19
19
|
- - "~>"
|
20
20
|
- !ruby/object:Gem::Version
|
21
|
-
version: '
|
21
|
+
version: '8.0'
|
22
22
|
- - ">="
|
23
23
|
- !ruby/object:Gem::Version
|
24
|
-
version:
|
24
|
+
version: 8.0.0
|
25
25
|
type: :runtime
|
26
26
|
prerelease: false
|
27
27
|
version_requirements: !ruby/object:Gem::Requirement
|
28
28
|
requirements:
|
29
29
|
- - "~>"
|
30
30
|
- !ruby/object:Gem::Version
|
31
|
-
version: '
|
31
|
+
version: '8.0'
|
32
32
|
- - ">="
|
33
33
|
- !ruby/object:Gem::Version
|
34
|
-
version:
|
34
|
+
version: 8.0.0
|
35
35
|
- !ruby/object:Gem::Dependency
|
36
36
|
name: rake
|
37
37
|
requirement: !ruby/object:Gem::Requirement
|
@@ -111,7 +111,6 @@ files:
|
|
111
111
|
- lib/gherkin/errors.rb
|
112
112
|
- lib/gherkin/gherkin-languages.json
|
113
113
|
- lib/gherkin/gherkin_line.rb
|
114
|
-
- lib/gherkin/id_generator.rb
|
115
114
|
- lib/gherkin/parser.rb
|
116
115
|
- lib/gherkin/pickles/compiler.rb
|
117
116
|
- lib/gherkin/stream/parser_message_stream.rb
|
@@ -124,7 +123,6 @@ files:
|
|
124
123
|
- spec/coverage.rb
|
125
124
|
- spec/gherkin/dialect_spec.rb
|
126
125
|
- spec/gherkin/gherkin_spec.rb
|
127
|
-
- spec/gherkin/id_generator_spec.rb
|
128
126
|
- spec/gherkin/stream/subprocess_message_stream_spec.rb
|
129
127
|
homepage: https://github.com/cucumber/gherkin-ruby
|
130
128
|
licenses:
|
@@ -155,11 +153,10 @@ rubyforge_project:
|
|
155
153
|
rubygems_version: 2.7.6.2
|
156
154
|
signing_key:
|
157
155
|
specification_version: 4
|
158
|
-
summary: gherkin-
|
156
|
+
summary: gherkin-9.0.0
|
159
157
|
test_files:
|
160
158
|
- spec/gherkin/dialect_spec.rb
|
161
159
|
- spec/gherkin/stream/subprocess_message_stream_spec.rb
|
162
|
-
- spec/gherkin/id_generator_spec.rb
|
163
160
|
- spec/gherkin/gherkin_spec.rb
|
164
161
|
- spec/capture_warnings.rb
|
165
162
|
- spec/coverage.rb
|
data/lib/gherkin/id_generator.rb
DELETED
@@ -1,22 +0,0 @@
|
|
1
|
-
require 'securerandom'
|
2
|
-
|
3
|
-
module Gherkin
|
4
|
-
module IdGenerator
|
5
|
-
class Incrementing
|
6
|
-
def initialize
|
7
|
-
@index = -1
|
8
|
-
end
|
9
|
-
|
10
|
-
def new_id
|
11
|
-
@index += 1
|
12
|
-
@index.to_s
|
13
|
-
end
|
14
|
-
end
|
15
|
-
|
16
|
-
class UUID
|
17
|
-
def new_id
|
18
|
-
SecureRandom.uuid
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
22
|
-
end
|
@@ -1,29 +0,0 @@
|
|
1
|
-
require 'rspec'
|
2
|
-
require 'gherkin/id_generator'
|
3
|
-
|
4
|
-
describe Gherkin::IdGenerator::Incrementing do
|
5
|
-
subject { Gherkin::IdGenerator::Incrementing.new }
|
6
|
-
|
7
|
-
context '#new_id' do
|
8
|
-
it 'returns 0 the first time' do
|
9
|
-
expect(subject.new_id).to eq("0")
|
10
|
-
end
|
11
|
-
|
12
|
-
it 'increments on every call' do
|
13
|
-
expect(subject.new_id).to eq("0")
|
14
|
-
expect(subject.new_id).to eq("1")
|
15
|
-
expect(subject.new_id).to eq("2")
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|
19
|
-
|
20
|
-
describe Gherkin::IdGenerator::UUID do
|
21
|
-
subject { Gherkin::IdGenerator::UUID.new }
|
22
|
-
|
23
|
-
context '#new_id' do
|
24
|
-
it 'generates a UUID' do
|
25
|
-
allowed_characters = "[0-9a-fA-F]"
|
26
|
-
expect(subject.new_id).to match(/#{allowed_characters}{8}\-#{allowed_characters}{4}\-#{allowed_characters}{4}\-#{allowed_characters}{4}\-#{allowed_characters}{12}/)
|
27
|
-
end
|
28
|
-
end
|
29
|
-
end
|