cucumber-gherkin 30.0.0 → 30.0.2

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.
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'cucumber/messages'
2
4
 
3
5
  module Gherkin
@@ -66,8 +68,11 @@ module Gherkin
66
68
  unless scenario.steps.empty?
67
69
  [].concat(background_steps).concat(scenario.steps).each do |step|
68
70
  last_keyword_type =
69
- step.keyword_type == Cucumber::Messages::StepKeywordType::CONJUNCTION ?
70
- last_keyword_type : step.keyword_type
71
+ if step.keyword_type == Cucumber::Messages::StepKeywordType::CONJUNCTION
72
+ last_keyword_type
73
+ else
74
+ step.keyword_type
75
+ end
71
76
  steps.push(Cucumber::Messages::PickleStep.new(**pickle_step_props(step, [], nil, last_keyword_type)))
72
77
  end
73
78
  end
@@ -96,15 +101,21 @@ module Gherkin
96
101
  unless scenario.steps.empty?
97
102
  background_steps.each do |step|
98
103
  last_keyword_type =
99
- step.keyword_type == Cucumber::Messages::StepKeywordType::CONJUNCTION ?
100
- last_keyword_type : step.keyword_type
104
+ if step.keyword_type == Cucumber::Messages::StepKeywordType::CONJUNCTION
105
+ last_keyword_type
106
+ else
107
+ step.keyword_type
108
+ end
101
109
  step_props = pickle_step_props(step, [], nil, last_keyword_type)
102
110
  steps.push(Cucumber::Messages::PickleStep.new(**step_props))
103
111
  end
104
112
  scenario.steps.each do |step|
105
113
  last_keyword_type =
106
- step.keyword_type == Cucumber::Messages::StepKeywordType::CONJUNCTION ?
107
- last_keyword_type : step.keyword_type
114
+ if step.keyword_type == Cucumber::Messages::StepKeywordType::CONJUNCTION
115
+ last_keyword_type
116
+ else
117
+ step.keyword_type
118
+ end
108
119
  step_props = pickle_step_props(step, variable_cells, values_row, last_keyword_type)
109
120
  steps.push(Cucumber::Messages::PickleStep.new(**step_props))
110
121
  end
@@ -123,7 +134,6 @@ module Gherkin
123
134
  ]
124
135
  )
125
136
  pickles.push(pickle)
126
-
127
137
  end
128
138
  end
129
139
  end
data/lib/gherkin/query.rb CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Gherkin
2
4
  class Query
3
5
  def initialize
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'cucumber/messages'
2
4
  require_relative '../parser'
3
5
  require_relative '../token_matcher'
data/lib/gherkin/token.rb CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Gherkin
2
4
  class Token < Struct.new(:line, :location)
3
5
  attr_accessor :matched_type, :matched_text, :matched_keyword, :matched_indent,
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Gherkin
2
4
  class TokenFormatterBuilder
3
5
  def initialize
@@ -5,11 +7,11 @@ module Gherkin
5
7
  end
6
8
 
7
9
  def reset
8
- @tokens_text = ''
10
+ @tokens = []
9
11
  end
10
12
 
11
13
  def build(token)
12
- @tokens_text << "#{format_token(token)}\n"
14
+ tokens << token
13
15
  end
14
16
 
15
17
  def start_rule(_rule_type); end
@@ -17,11 +19,15 @@ module Gherkin
17
19
  def end_rule(_rule_type); end
18
20
 
19
21
  def get_result
20
- @tokens_text
22
+ tokens.map { |token| "#{format_token(token)}\n" }.join
21
23
  end
22
24
 
23
25
  private
24
26
 
27
+ def tokens
28
+ @tokens ||= []
29
+ end
30
+
25
31
  def format_token(token)
26
32
  return 'EOF' if token.eof?
27
33
 
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'cucumber/messages'
2
4
  require_relative 'dialect'
3
5
  require_relative 'errors'
@@ -35,7 +37,7 @@ module Gherkin
35
37
 
36
38
  def match_ScenarioLine(token)
37
39
  match_title_line(token, :ScenarioLine, @dialect.scenario_keywords) ||
38
- match_title_line(token, :ScenarioLine, @dialect.scenario_outline_keywords)
40
+ match_title_line(token, :ScenarioLine, @dialect.scenario_outline_keywords)
39
41
  end
40
42
 
41
43
  def match_BackgroundLine(token)
@@ -83,7 +85,7 @@ module Gherkin
83
85
  if @active_doc_string_separator.nil?
84
86
  # open
85
87
  _match_DocStringSeparator(token, '"""', true) ||
86
- _match_DocStringSeparator(token, '```', true)
88
+ _match_DocStringSeparator(token, '```', true)
87
89
  else
88
90
  # close
89
91
  _match_DocStringSeparator(token, @active_doc_string_separator, false)
@@ -121,11 +123,12 @@ module Gherkin
121
123
  end
122
124
 
123
125
  def match_StepLine(token)
124
- keywords = @dialect.given_keywords +
125
- @dialect.when_keywords +
126
- @dialect.then_keywords +
127
- @dialect.and_keywords +
128
- @dialect.but_keywords
126
+ keywords =
127
+ @dialect.given_keywords +
128
+ @dialect.when_keywords +
129
+ @dialect.then_keywords +
130
+ @dialect.and_keywords +
131
+ @dialect.but_keywords
129
132
 
130
133
  keyword = keywords.detect { |k| token.line.start_with?(k) }
131
134
 
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'stringio'
2
4
  require_relative 'token'
3
5
  require_relative 'gherkin_line'
@@ -26,8 +28,10 @@ module Gherkin
26
28
 
27
29
  def read
28
30
  location = { line: @line_number += 1 }
29
- if @io.nil? || line = @io.gets
30
- gherkin_line = line ? GherkinLine.new(line, location[:line]) : nil
31
+ if @io.nil?
32
+ Token.new(nil, location)
33
+ elsif (line = @io.gets)
34
+ gherkin_line = GherkinLine.new(line, location[:line])
31
35
  Token.new(gherkin_line, location)
32
36
  else
33
37
  @io.close unless @io.closed? # ARGF closes the last file after final gets
data/lib/gherkin.rb CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require_relative 'gherkin/stream/parser_message_stream'
2
4
 
3
5
  module Gherkin
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cucumber-gherkin
3
3
  version: !ruby/object:Gem::Version
4
- version: 30.0.0
4
+ version: 30.0.2
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: 2024-10-24 00:00:00.000000000 Z
13
+ date: 2024-11-14 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: cucumber-messages
@@ -126,8 +126,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
126
126
  - !ruby/object:Gem::Version
127
127
  version: 3.2.8
128
128
  requirements: []
129
- rubygems_version: 3.5.16
129
+ rubygems_version: 3.5.22
130
130
  signing_key:
131
131
  specification_version: 4
132
- summary: cucumber-gherkin-30.0.0
132
+ summary: cucumber-gherkin-30.0.2
133
133
  test_files: []