cucumber-gherkin 28.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ece34082ea75a09a5cbeae3980afa533c15807b6bfdcebff24b757f01dbccc5e
4
- data.tar.gz: c36a3c7b537533d54653d8ac71e4f7514a20a9898712c04c3c19dc49881fbbe8
3
+ metadata.gz: 2d2a74d7544ccbaad3636051f909746a07a82b2a408a1497c5d5e22aef7cc5e3
4
+ data.tar.gz: c3df41f699ce69242dbc4f031bf21d9f806c097d73abf9977d43c8896ce6803e
5
5
  SHA512:
6
- metadata.gz: 6c81377d145f9944910004eeb22b75570ecc850d4c2cccbb9d851e2b9c89bcdbd5e54fafcc531bdb27a7833275ebf3be6504bc6dee23f457a401e8ebcbbf459c
7
- data.tar.gz: 553a43f5d6e5ce49d0573ba64b4c42b5089519c0e56c66b20dd92fb70e9790db6e3000581d922df5f312389a6860cc1d59adc4ef300224f280680874cd94e099
6
+ metadata.gz: 1792227ceb4578bd08cdd47d59baf77d1eb6419c08e233ced30415ed53725e648f1ea6723a2529edf7808094ced7702befca1d8c1a823ccf8b5922682503e4b1
7
+ data.tar.gz: c4645bec78256b431bffbf2092bb9fd926de65fc66456efd01978778042d30ec72fc7155fa230d71cc47ded7651bb60534510fe30d62e6a52031b85828d71334
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2017 Cucumber Ltd, Gaspar Nagy, Björn Rasmusson, Peter Sergeant, and contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
data/bin/gherkin CHANGED
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env ruby
2
- $VERBOSE=nil # Shut up JRuby warnings on Travis
3
- $LOAD_PATH.unshift(File.join(File.dirname(__FILE__),"../lib"))
2
+
3
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '../lib'))
4
4
 
5
5
  require 'optparse'
6
6
  require 'json'
@@ -15,32 +15,33 @@ options = {
15
15
  }
16
16
 
17
17
  OptionParser.new do |opts|
18
- opts.on("--[no-]source", "Don't print source messages") do |v|
19
- options[:include_source] = v
18
+ opts.on('--[no-]source', "Don't print source messages") do |value|
19
+ options[:include_source] = value
20
20
  end
21
- opts.on("--[no-]ast", "Don't print ast messages") do |v|
22
- options[:include_gherkin_document] = v
21
+ opts.on('--[no-]ast', "Don't print ast messages") do |value|
22
+ options[:include_gherkin_document] = value
23
23
  end
24
- opts.on("--[no-]pickles", "Don't print pickle messages") do |v|
25
- options[:include_pickles] = v
24
+ opts.on('--[no-]pickles', "Don't print pickle messages") do |value|
25
+ options[:include_pickles] = value
26
26
  end
27
- opts.on("--predictable-ids", "Generate incrementing ids rather than UUIDs") do |v|
28
- options[:id_generator] = Cucumber::Messages::IdGenerator::Incrementing.new if v
27
+ opts.on('--predictable-ids', 'Generate incrementing ids rather than UUIDs') do |value|
28
+ options[:id_generator] = Cucumber::Messages::Helpers::IdGenerator::Incrementing.new if value
29
29
  end
30
30
  end.parse!
31
31
 
32
- def process_messages(messages, options)
32
+ def process_messages(messages, _options)
33
33
  messages.each do |message|
34
- STDOUT.write(message.to_json)
35
- STDOUT.write("\n")
34
+ $stdout.write(message.to_json)
35
+ $stdout.write("\n")
36
36
  end
37
37
  end
38
38
 
39
- if ARGV.empty?
40
- # Read from STDIN
41
- messages = Cucumber::Messages::NdjsonToMessageEnumerator.new(STDIN)
42
- else
43
- messages = Gherkin.from_paths(ARGV, options)
44
- end
39
+ messages =
40
+ if ARGV.empty?
41
+ # Read from $stdin
42
+ Cucumber::Messages::Helpers::NdjsonToMessageEnumerator.new($stdin)
43
+ else
44
+ Gherkin.from_paths(ARGV, options)
45
+ end
45
46
 
46
47
  process_messages(messages, options)
@@ -24,10 +24,12 @@ module Gherkin
24
24
 
25
25
  def build(token)
26
26
  if token.matched_type == :Comment
27
- @comments.push(Cucumber::Messages::Comment.new(
28
- location: get_location(token, 0),
29
- text: token.matched_text
30
- ))
27
+ @comments.push(
28
+ Cucumber::Messages::Comment.new(
29
+ location: get_location(token, 0),
30
+ text: token.matched_text
31
+ )
32
+ )
31
33
  else
32
34
  current_node.add(token.matched_type, token)
33
35
  end
@@ -56,11 +58,13 @@ module Gherkin
56
58
 
57
59
  tags_node.get_tokens(:TagLine).each do |token|
58
60
  token.matched_items.each do |tag_item|
59
- tags.push(Cucumber::Messages::Tag.new(
60
- location: get_location(token, tag_item.column),
61
- name: tag_item.text,
62
- id: @id_generator.new_id
63
- ))
61
+ tags.push(
62
+ Cucumber::Messages::Tag.new(
63
+ location: get_location(token, tag_item.column),
64
+ name: tag_item.text,
65
+ id: @id_generator.new_id
66
+ )
67
+ )
64
68
  end
65
69
  end
66
70
 
@@ -81,11 +85,10 @@ module Gherkin
81
85
 
82
86
  def ensure_cell_count(rows)
83
87
  return if rows.empty?
88
+
84
89
  cell_count = rows[0].cells.length
85
90
  rows.each do |row|
86
- if row.cells.length != cell_count
87
- raise AstBuilderException.new("inconsistent cell count within the table", row.location.to_h)
88
- end
91
+ raise AstBuilderException.new('inconsistent cell count within the table', row.location.to_h) if row.cells.length != cell_count
89
92
  end
90
93
  end
91
94
 
@@ -196,14 +199,16 @@ module Gherkin
196
199
  line_tokens = node.get_tokens(:Other)
197
200
  # Trim trailing empty lines
198
201
  last_non_empty = line_tokens.rindex { |token| !token.line.trimmed_line_text.empty? }
199
- description = line_tokens[0..last_non_empty].map { |token| token.matched_text }.join("\n")
200
- return description
202
+ line_tokens[0..last_non_empty].map { |token| token.matched_text }.join("\n")
203
+
201
204
  when :Feature
202
205
  header = node.get_single(:FeatureHeader)
203
206
  return unless header
207
+
204
208
  tags = get_tags(header)
205
209
  feature_line = header.get_token(:FeatureLine)
206
210
  return unless feature_line
211
+
207
212
  children = []
208
213
  background = node.get_single(:Background)
209
214
  children.push(Cucumber::Messages::FeatureChild.new(background: background)) if background
@@ -228,8 +233,10 @@ module Gherkin
228
233
  when :Rule
229
234
  header = node.get_single(:RuleHeader)
230
235
  return unless header
236
+
231
237
  rule_line = header.get_token(:RuleLine)
232
238
  return unless rule_line
239
+
233
240
  tags = get_tags(header)
234
241
  children = []
235
242
  background = node.get_single(:Background)
@@ -255,7 +262,7 @@ module Gherkin
255
262
  feature: feature
256
263
  )
257
264
  else
258
- return node
265
+ node
259
266
  end
260
267
  end
261
268
  end
@@ -2,13 +2,14 @@ require 'cucumber/messages'
2
2
  require 'json'
3
3
 
4
4
  module Gherkin
5
- DIALECT_FILE_PATH = File.expand_path("gherkin-languages.json", File.dirname(__FILE__))
5
+ DIALECT_FILE_PATH = File.expand_path('gherkin-languages.json', File.dirname(__FILE__))
6
6
  DIALECTS = JSON.parse File.open(DIALECT_FILE_PATH, 'r:UTF-8').read
7
7
 
8
8
  class Dialect
9
9
  def self.for(name)
10
10
  spec = DIALECTS[name]
11
11
  return nil unless spec
12
+
12
13
  new(spec)
13
14
  end
14
15
 
@@ -33,7 +33,7 @@ module Gherkin
33
33
  def initialize(received_token, expected_token_types, state_comment)
34
34
  message = "expected: #{expected_token_types.join(", ")}, got '#{received_token.token_value.strip}'"
35
35
  column = received_token.location[:column]
36
- location = (column.nil? || column.zero?) ? {line: received_token.location[:line], column: received_token.line.indent + 1} : received_token.location
36
+ location = (column.nil? || column.zero?) ? { line: received_token.location[:line], column: received_token.line.indent + 1 } : received_token.location
37
37
  super(message, location)
38
38
  end
39
39
  end
@@ -278,7 +278,7 @@
278
278
  "Nə vaxt ki "
279
279
  ]
280
280
  },
281
- "be": {
281
+ "be": {
282
282
  "and": [
283
283
  "* ",
284
284
  "I ",
@@ -1401,14 +1401,14 @@
1401
1401
  "ga": {
1402
1402
  "and": [
1403
1403
  "* ",
1404
- "Agus"
1404
+ "Agus "
1405
1405
  ],
1406
1406
  "background": [
1407
1407
  "Cúlra"
1408
1408
  ],
1409
1409
  "but": [
1410
1410
  "* ",
1411
- "Ach"
1411
+ "Ach "
1412
1412
  ],
1413
1413
  "examples": [
1414
1414
  "Samplaí"
@@ -1418,10 +1418,10 @@
1418
1418
  ],
1419
1419
  "given": [
1420
1420
  "* ",
1421
- "Cuir i gcás go",
1422
- "Cuir i gcás nach",
1423
- "Cuir i gcás gur",
1424
- "Cuir i gcás nár"
1421
+ "Cuir i gcás go ",
1422
+ "Cuir i gcás nach ",
1423
+ "Cuir i gcás gur ",
1424
+ "Cuir i gcás nár "
1425
1425
  ],
1426
1426
  "name": "Irish",
1427
1427
  "native": "Gaeilge",
@@ -1437,14 +1437,14 @@
1437
1437
  ],
1438
1438
  "then": [
1439
1439
  "* ",
1440
- "Ansin"
1440
+ "Ansin "
1441
1441
  ],
1442
1442
  "when": [
1443
1443
  "* ",
1444
- "Nuair a",
1445
- "Nuair nach",
1446
- "Nuair ba",
1447
- "Nuair nár"
1444
+ "Nuair a ",
1445
+ "Nuair nach ",
1446
+ "Nuair ba ",
1447
+ "Nuair nár "
1448
1448
  ]
1449
1449
  },
1450
1450
  "gj": {
@@ -1474,7 +1474,7 @@
1474
1474
  "name": "Gujarati",
1475
1475
  "native": "ગુજરાતી",
1476
1476
  "rule": [
1477
- "Rule"
1477
+ "નિયમ"
1478
1478
  ],
1479
1479
  "scenario": [
1480
1480
  "ઉદાહરણ",
@@ -2133,15 +2133,15 @@
2133
2133
  "ko": {
2134
2134
  "and": [
2135
2135
  "* ",
2136
- "그리고"
2136
+ "그리고 "
2137
2137
  ],
2138
2138
  "background": [
2139
2139
  "배경"
2140
2140
  ],
2141
2141
  "but": [
2142
2142
  "* ",
2143
- "하지만",
2144
- "단"
2143
+ "하지만 ",
2144
+ "단 "
2145
2145
  ],
2146
2146
  "examples": [
2147
2147
  "예"
@@ -2151,8 +2151,8 @@
2151
2151
  ],
2152
2152
  "given": [
2153
2153
  "* ",
2154
- "조건",
2155
- "먼저"
2154
+ "조건 ",
2155
+ "먼저 "
2156
2156
  ],
2157
2157
  "name": "Korean",
2158
2158
  "native": "한국어",
@@ -2167,12 +2167,12 @@
2167
2167
  ],
2168
2168
  "then": [
2169
2169
  "* ",
2170
- "그러면"
2170
+ "그러면 "
2171
2171
  ],
2172
2172
  "when": [
2173
2173
  "* ",
2174
- "만일",
2175
- "만약"
2174
+ "만일 ",
2175
+ "만약 "
2176
2176
  ]
2177
2177
  },
2178
2178
  "lt": {
@@ -3015,7 +3015,6 @@
3015
3015
  "Правило"
3016
3016
  ],
3017
3017
  "scenario": [
3018
- "Пример",
3019
3018
  "Сценарио",
3020
3019
  "Пример"
3021
3020
  ],
@@ -3134,7 +3133,7 @@
3134
3133
  "ta": {
3135
3134
  "and": [
3136
3135
  "* ",
3137
- "மேலும் ",
3136
+ "மேலும் ",
3138
3137
  "மற்றும் "
3139
3138
  ],
3140
3139
  "background": [
@@ -3142,7 +3141,7 @@
3142
3141
  ],
3143
3142
  "but": [
3144
3143
  "* ",
3145
- "ஆனால் "
3144
+ "ஆனால் "
3146
3145
  ],
3147
3146
  "examples": [
3148
3147
  "எடுத்துக்காட்டுகள்",
@@ -1,6 +1,7 @@
1
1
  module Gherkin
2
2
  class GherkinLine
3
3
  attr_reader :indent, :trimmed_line_text
4
+
4
5
  def initialize(line_text, line_number)
5
6
  @line_text = line_text
6
7
  @line_number = line_number
@@ -13,7 +14,7 @@ module Gherkin
13
14
  end
14
15
 
15
16
  def start_with_title_keyword?(keyword)
16
- start_with?(keyword+':') # The C# impl is more complicated. Find out why.
17
+ start_with?(keyword + ':') # The C# impl is more complicated. Find out why.
17
18
  end
18
19
 
19
20
  def get_rest_trimmed(length)
@@ -66,7 +67,7 @@ module Gherkin
66
67
  cell = ''
67
68
  start_col = col + 1
68
69
  elsif char == '\\'
69
- char = row[col]
70
+ char = row[col] || ''
70
71
  col += 1
71
72
  if char == 'n'
72
73
  cell += "\n"
@@ -89,9 +90,7 @@ module Gherkin
89
90
  tags = []
90
91
  items.each { |untrimmed|
91
92
  item = untrimmed.strip
92
- if item.length == 0
93
- next
94
- end
93
+ next if item.length == 0
95
94
 
96
95
  unless item =~ /^\S+$/
97
96
  location = { line: @line_number, column: column }