cucumber-gherkin 27.0.0 → 30.0.4

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: fbc83b6f938a3a8340c9294af1748e30df74132af1764c44c6497ed791afc66a
4
- data.tar.gz: 164663118b966fdb4bbefa12794d73915c83b3cbaa9a260df078694b74336c72
3
+ metadata.gz: f9c966029bc07cd707a228c9db59ddce9e61caa93a627f7bc71bf94f72c7ea5d
4
+ data.tar.gz: e5fccd4d666fc108a62537cf44acef7f28feef42a39bd99d33f1ded1a2006b7e
5
5
  SHA512:
6
- metadata.gz: 608412c8b5ed734d338959803716ea4813c2c036cc3a175076ade152a089d559b56d5d75a82f6bda5dfb8a1e16ba3f01ebcca1e355628e1f9669cabb62170e61
7
- data.tar.gz: 47ee4d057e778ea4901184bfd279b61eaf0546e72930e214d9c9f4a1e577d72eff704a6bd7766f413259ad73301d5fb1dc8053dbec009bf8d3b9e6338bae4161
6
+ metadata.gz: 062ae9996232f0b9f9f276c75ebbd470e47be2e2562b1353d1e9b530347fff5b3190d2557a7193cf498c5881359f004f2f4a8ea7fdea99fa2749a40b8ca64959
7
+ data.tar.gz: c940fb2430d7629a82452fbeadf2a8c869fea0b4d505a77465f3e467c94df51e2367a4abfa02284d726a29f3dd1da7f0cce4e7eb60108cfe5a4d01123fed0569
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,7 @@
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
+ # frozen_string_literal: true
3
+
4
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '../lib'))
4
5
 
5
6
  require 'optparse'
6
7
  require 'json'
@@ -15,32 +16,33 @@ options = {
15
16
  }
16
17
 
17
18
  OptionParser.new do |opts|
18
- opts.on("--[no-]source", "Don't print source messages") do |v|
19
- options[:include_source] = v
19
+ opts.on('--[no-]source', "Don't print source messages") do |value|
20
+ options[:include_source] = value
20
21
  end
21
- opts.on("--[no-]ast", "Don't print ast messages") do |v|
22
- options[:include_gherkin_document] = v
22
+ opts.on('--[no-]ast', "Don't print ast messages") do |value|
23
+ options[:include_gherkin_document] = value
23
24
  end
24
- opts.on("--[no-]pickles", "Don't print pickle messages") do |v|
25
- options[:include_pickles] = v
25
+ opts.on('--[no-]pickles', "Don't print pickle messages") do |value|
26
+ options[:include_pickles] = value
26
27
  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
28
+ opts.on('--predictable-ids', 'Generate incrementing ids rather than UUIDs') do |value|
29
+ options[:id_generator] = Cucumber::Messages::Helpers::IdGenerator::Incrementing.new if value
29
30
  end
30
31
  end.parse!
31
32
 
32
- def process_messages(messages, options)
33
+ def process_messages(messages, _options)
33
34
  messages.each do |message|
34
- STDOUT.write(message.to_json)
35
- STDOUT.write("\n")
35
+ $stdout.write(message.to_json)
36
+ $stdout.write("\n")
36
37
  end
37
38
  end
38
39
 
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
40
+ messages =
41
+ if ARGV.empty?
42
+ # Read from $stdin
43
+ Cucumber::Messages::Helpers::NdjsonToMessageEnumerator.new($stdin)
44
+ else
45
+ Gherkin.from_paths(ARGV, options)
46
+ end
45
47
 
46
48
  process_messages(messages, options)
data/bin/gherkin-ruby CHANGED
@@ -1,2 +1,4 @@
1
1
  #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
2
4
  load(File.dirname(__FILE__) + '/gherkin')
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'cucumber/messages'
2
4
  require_relative 'ast_node'
3
5
 
@@ -17,17 +19,19 @@ module Gherkin
17
19
  @stack.push AstNode.new(rule_type)
18
20
  end
19
21
 
20
- def end_rule(rule_type)
22
+ def end_rule(_rule_type)
21
23
  node = @stack.pop
22
24
  current_node.add(node.rule_type, transform_node(node))
23
25
  end
24
26
 
25
27
  def build(token)
26
28
  if token.matched_type == :Comment
27
- @comments.push(Cucumber::Messages::Comment.new(
28
- location: get_location(token, 0),
29
- text: token.matched_text
30
- ))
29
+ @comments.push(
30
+ Cucumber::Messages::Comment.new(
31
+ location: get_location(token, 0),
32
+ text: token.matched_text
33
+ )
34
+ )
31
35
  else
32
36
  current_node.add(token.matched_type, token)
33
37
  end
@@ -56,11 +60,13 @@ module Gherkin
56
60
 
57
61
  tags_node.get_tokens(:TagLine).each do |token|
58
62
  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
- ))
63
+ tags.push(
64
+ Cucumber::Messages::Tag.new(
65
+ location: get_location(token, tag_item.column),
66
+ name: tag_item.text,
67
+ id: @id_generator.new_id
68
+ )
69
+ )
64
70
  end
65
71
  end
66
72
 
@@ -75,17 +81,15 @@ module Gherkin
75
81
  cells: get_cells(token)
76
82
  )
77
83
  end
78
- ensure_cell_count(rows)
79
- rows
84
+ rows.tap { ensure_cell_count(rows) }
80
85
  end
81
86
 
82
87
  def ensure_cell_count(rows)
83
88
  return if rows.empty?
89
+
84
90
  cell_count = rows[0].cells.length
85
91
  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
92
+ raise AstBuilderException.new('inconsistent cell count within the table', row.location.to_h) if row.cells.length != cell_count
89
93
  end
90
94
  end
91
95
 
@@ -113,7 +117,7 @@ module Gherkin
113
117
  data_table = node.get_single(:DataTable)
114
118
  doc_string = node.get_single(:DocString)
115
119
 
116
- step = Cucumber::Messages::Step.new(
120
+ Cucumber::Messages::Step.new(
117
121
  location: get_location(step_line, 0),
118
122
  keyword: step_line.matched_keyword,
119
123
  keyword_type: step_line.matched_keyword_type,
@@ -196,14 +200,16 @@ module Gherkin
196
200
  line_tokens = node.get_tokens(:Other)
197
201
  # Trim trailing empty lines
198
202
  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
203
+ line_tokens[0..last_non_empty].map { |token| token.matched_text }.join("\n")
204
+
201
205
  when :Feature
202
206
  header = node.get_single(:FeatureHeader)
203
207
  return unless header
208
+
204
209
  tags = get_tags(header)
205
210
  feature_line = header.get_token(:FeatureLine)
206
211
  return unless feature_line
212
+
207
213
  children = []
208
214
  background = node.get_single(:Background)
209
215
  children.push(Cucumber::Messages::FeatureChild.new(background: background)) if background
@@ -228,8 +234,10 @@ module Gherkin
228
234
  when :Rule
229
235
  header = node.get_single(:RuleHeader)
230
236
  return unless header
237
+
231
238
  rule_line = header.get_token(:RuleLine)
232
239
  return unless rule_line
240
+
233
241
  tags = get_tags(header)
234
242
  children = []
235
243
  background = node.get_single(:Background)
@@ -255,7 +263,7 @@ module Gherkin
255
263
  feature: feature
256
264
  )
257
265
  else
258
- return node
266
+ node
259
267
  end
260
268
  end
261
269
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Gherkin
2
4
  class AstNode
3
5
  attr_reader :rule_type
@@ -1,14 +1,17 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'cucumber/messages'
2
4
  require 'json'
3
5
 
4
6
  module Gherkin
5
- DIALECT_FILE_PATH = File.expand_path("gherkin-languages.json", File.dirname(__FILE__))
7
+ DIALECT_FILE_PATH = File.expand_path('gherkin-languages.json', File.dirname(__FILE__))
6
8
  DIALECTS = JSON.parse File.open(DIALECT_FILE_PATH, 'r:UTF-8').read
7
9
 
8
10
  class Dialect
9
11
  def self.for(name)
10
12
  spec = DIALECTS[name]
11
13
  return nil unless spec
14
+
12
15
  new(spec)
13
16
  end
14
17
 
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Gherkin
2
4
  class ParserError < StandardError; end
3
5
  class AstNodeNotLocatedException < StandardError; end
@@ -30,16 +32,16 @@ module Gherkin
30
32
  end
31
33
 
32
34
  class UnexpectedTokenException < ParserException
33
- def initialize(received_token, expected_token_types, state_comment)
35
+ def initialize(received_token, expected_token_types, _state_comment)
34
36
  message = "expected: #{expected_token_types.join(", ")}, got '#{received_token.token_value.strip}'"
35
37
  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
38
+ location = (column.nil? || column.zero?) ? { line: received_token.location[:line], column: received_token.line.indent + 1 } : received_token.location
37
39
  super(message, location)
38
40
  end
39
41
  end
40
42
 
41
43
  class UnexpectedEOFException < ParserException
42
- def initialize(received_token, expected_token_types, state_comment)
44
+ def initialize(received_token, expected_token_types, _state_comment)
43
45
  message = "unexpected end of file, expected: #{expected_token_types.join(", ")}"
44
46
  super(message, received_token.location)
45
47
  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,15 +1418,15 @@
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",
1428
1428
  "rule": [
1429
- "Rule"
1429
+ "Riail"
1430
1430
  ],
1431
1431
  "scenario": [
1432
1432
  "Sampla",
@@ -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
  "எடுத்துக்காட்டுகள்",
@@ -3576,7 +3575,7 @@
3576
3575
  "name": "Vietnamese",
3577
3576
  "native": "Tiếng Việt",
3578
3577
  "rule": [
3579
- "Rule"
3578
+ "Quy tắc"
3580
3579
  ],
3581
3580
  "scenario": [
3582
3581
  "Tình huống",
@@ -1,6 +1,9 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Gherkin
2
4
  class GherkinLine
3
5
  attr_reader :indent, :trimmed_line_text
6
+
4
7
  def initialize(line_text, line_number)
5
8
  @line_text = line_text
6
9
  @line_number = line_number
@@ -13,7 +16,7 @@ module Gherkin
13
16
  end
14
17
 
15
18
  def start_with_title_keyword?(keyword)
16
- start_with?(keyword+':') # The C# impl is more complicated. Find out why.
19
+ start_with?(keyword + ':') # The C# impl is more complicated. Find out why.
17
20
  end
18
21
 
19
22
  def get_rest_trimmed(length)
@@ -66,7 +69,7 @@ module Gherkin
66
69
  cell = ''
67
70
  start_col = col + 1
68
71
  elsif char == '\\'
69
- char = row[col]
72
+ char = row[col] || ''
70
73
  col += 1
71
74
  if char == 'n'
72
75
  cell += "\n"
@@ -87,11 +90,9 @@ module Gherkin
87
90
  items = uncommented_line.split('@')
88
91
 
89
92
  tags = []
90
- items.each { |untrimmed|
93
+ items.each do |untrimmed|
91
94
  item = untrimmed.strip
92
- if item.length == 0
93
- next
94
- end
95
+ next if item.length == 0
95
96
 
96
97
  unless item =~ /^\S+$/
97
98
  location = { line: @line_number, column: column }
@@ -100,7 +101,7 @@ module Gherkin
100
101
 
101
102
  tags << Span.new(column, '@' + item)
102
103
  column += untrimmed.length + 1
103
- }
104
+ end
104
105
  tags
105
106
  end
106
107