cucumber-gherkin 29.0.0 → 30.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: fb339971170bdf897bf51a6d7cc8e63fee16894e19c4ef4473338019c74210e4
4
- data.tar.gz: 90052ec9d9cff63eaca6f7d0a69b86e898e0c32f6ad04952d7bdf39904070cec
3
+ metadata.gz: 2d2a74d7544ccbaad3636051f909746a07a82b2a408a1497c5d5e22aef7cc5e3
4
+ data.tar.gz: c3df41f699ce69242dbc4f031bf21d9f806c097d73abf9977d43c8896ce6803e
5
5
  SHA512:
6
- metadata.gz: 8afa90ac6ba2c8b4730e64038d3a6e7c733698e8b10c1e10dbd6f82356fab0baa679944aa3c4aadf850f77aba270f28b53dc3fd72137e64785cc4aecfee980af
7
- data.tar.gz: bd312859d9a2b2c1dc5ae2bcd9ae19b527e83d1f0a645a3f8e60f913f08552f9f6629ac7840d6950263859bf7ace7ee58f3c8221586ca1f2e0ef1d9ca2266723
6
+ metadata.gz: 1792227ceb4578bd08cdd47d59baf77d1eb6419c08e233ced30415ed53725e648f1ea6723a2529edf7808094ced7702befca1d8c1a823ccf8b5922682503e4b1
7
+ data.tar.gz: c4645bec78256b431bffbf2092bb9fd926de65fc66456efd01978778042d30ec72fc7155fa230d71cc47ded7651bb60534510fe30d62e6a52031b85828d71334
data/bin/gherkin CHANGED
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
- $LOAD_PATH.unshift(File.join(File.dirname(__FILE__),"../lib"))
3
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '../lib'))
4
4
 
5
5
  require 'optparse'
6
6
  require 'json'
@@ -29,18 +29,19 @@ OptionParser.new do |opts|
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::Helpers::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
@@ -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)
@@ -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 }