cucumber-gherkin 29.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 +4 -4
 - data/bin/gherkin +11 -10
 - data/lib/gherkin/ast_builder.rb +22 -15
 - data/lib/gherkin/dialect.rb +2 -1
 - data/lib/gherkin/errors.rb +1 -1
 - data/lib/gherkin/gherkin_line.rb +3 -4
 - data/lib/gherkin/parser.rb +370 -370
 - data/lib/gherkin/pickles/compiler.rb +4 -7
 - data/lib/gherkin/query.rb +4 -0
 - data/lib/gherkin/stream/parser_message_stream.rb +14 -13
 - data/lib/gherkin/token_formatter_builder.rb +9 -9
 - data/lib/gherkin/token_matcher.rb +10 -12
 - data/lib/gherkin/token_scanner.rb +2 -3
 - data/lib/gherkin.rb +9 -11
 - metadata +6 -6
 
    
        checksums.yaml
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            ---
         
     | 
| 
       2 
2 
     | 
    
         
             
            SHA256:
         
     | 
| 
       3 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       4 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 3 
     | 
    
         
            +
              metadata.gz: 2d2a74d7544ccbaad3636051f909746a07a82b2a408a1497c5d5e22aef7cc5e3
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: c3df41f699ce69242dbc4f031bf21d9f806c097d73abf9977d43c8896ce6803e
         
     | 
| 
       5 
5 
     | 
    
         
             
            SHA512:
         
     | 
| 
       6 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       7 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 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__), 
     | 
| 
      
 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,  
     | 
| 
      
 32 
     | 
    
         
            +
            def process_messages(messages, _options)
         
     | 
| 
       33 
33 
     | 
    
         
             
              messages.each do |message|
         
     | 
| 
       34 
     | 
    
         
            -
                 
     | 
| 
       35 
     | 
    
         
            -
                 
     | 
| 
      
 34 
     | 
    
         
            +
                $stdout.write(message.to_json)
         
     | 
| 
      
 35 
     | 
    
         
            +
                $stdout.write("\n")
         
     | 
| 
       36 
36 
     | 
    
         
             
              end
         
     | 
| 
       37 
37 
     | 
    
         
             
            end
         
     | 
| 
       38 
38 
     | 
    
         | 
| 
       39 
     | 
    
         
            -
             
     | 
| 
       40 
     | 
    
         
            -
               
     | 
| 
       41 
     | 
    
         
            -
             
     | 
| 
       42 
     | 
    
         
            -
             
     | 
| 
       43 
     | 
    
         
            -
               
     | 
| 
       44 
     | 
    
         
            -
             
     | 
| 
      
 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)
         
     | 
    
        data/lib/gherkin/ast_builder.rb
    CHANGED
    
    | 
         @@ -24,10 +24,12 @@ module Gherkin 
     | 
|
| 
       24 
24 
     | 
    
         | 
| 
       25 
25 
     | 
    
         
             
                def build(token)
         
     | 
| 
       26 
26 
     | 
    
         
             
                  if token.matched_type == :Comment
         
     | 
| 
       27 
     | 
    
         
            -
                    @comments.push( 
     | 
| 
       28 
     | 
    
         
            -
                       
     | 
| 
       29 
     | 
    
         
            -
             
     | 
| 
       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( 
     | 
| 
       60 
     | 
    
         
            -
                         
     | 
| 
       61 
     | 
    
         
            -
             
     | 
| 
       62 
     | 
    
         
            -
             
     | 
| 
       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 
     | 
    
         
            -
                     
     | 
| 
       200 
     | 
    
         
            -
             
     | 
| 
      
 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 
     | 
    
         
            -
                     
     | 
| 
      
 265 
     | 
    
         
            +
                    node
         
     | 
| 
       259 
266 
     | 
    
         
             
                  end
         
     | 
| 
       260 
267 
     | 
    
         
             
                end
         
     | 
| 
       261 
268 
     | 
    
         
             
              end
         
     | 
    
        data/lib/gherkin/dialect.rb
    CHANGED
    
    | 
         @@ -2,13 +2,14 @@ require 'cucumber/messages' 
     | 
|
| 
       2 
2 
     | 
    
         
             
            require 'json'
         
     | 
| 
       3 
3 
     | 
    
         | 
| 
       4 
4 
     | 
    
         
             
            module Gherkin
         
     | 
| 
       5 
     | 
    
         
            -
              DIALECT_FILE_PATH = File.expand_path( 
     | 
| 
      
 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 
     | 
    
         | 
    
        data/lib/gherkin/errors.rb
    CHANGED
    
    | 
         @@ -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 = 
     | 
| 
      
 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
         
     | 
    
        data/lib/gherkin/gherkin_line.rb
    CHANGED
    
    | 
         @@ -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 }
         
     |