Sha256: 17fe370f7f7c67b2bed5590bc40ad57eb96fffca676304472b1f5c1e66e24a68

Contents?: true

Size: 770 Bytes

Versions: 16

Compression:

Stored size: 770 Bytes

Contents

module Gherkin
  class TokenFormatterBuilder
    def initialize
      reset
    end

    def reset
      @tokens_text = ""
    end

    def build(token)
      @tokens_text << "#{format_token(token)}\n"
    end

    def start_rule(rule_type)
    end

    def end_rule(rule_type)
    end

    def get_result
      @tokens_text
    end

    private
    def format_token(token)
      return "EOF" if token.eof?

      sprintf "(%s:%s)%s:%s/%s/%s",
        token.location[:line],
        token.location[:column],
        token.matched_type,
        token.matched_keyword ? sprintf("(%s)%s", token.matched_keyword_type, token.matched_keyword) : "",
        token.matched_text,
        Array(token.matched_items).map { |i| "#{i.column}:#{i.text}"}.join(',')
    end

  end
end

Version data entries

16 entries across 16 versions & 2 rubygems

Version Path
cucumber-gherkin-29.0.0 lib/gherkin/token_formatter_builder.rb
cucumber-gherkin-28.0.0 lib/gherkin/token_formatter_builder.rb
honeybadger-5.4.0 vendor/bundle/ruby/3.2.0/gems/cucumber-gherkin-26.2.0/lib/gherkin/token_formatter_builder.rb
honeybadger-5.3.0 vendor/bundle/ruby/3.2.0/gems/cucumber-gherkin-26.2.0/lib/gherkin/token_formatter_builder.rb
cucumber-gherkin-27.0.0 lib/gherkin/token_formatter_builder.rb
cucumber-gherkin-26.2.0 lib/gherkin/token_formatter_builder.rb
cucumber-gherkin-26.1.0 lib/gherkin/token_formatter_builder.rb
cucumber-gherkin-26.0.3 lib/gherkin/token_formatter_builder.rb
cucumber-gherkin-26.0.2 lib/gherkin/token_formatter_builder.rb
cucumber-gherkin-26.0.1 lib/gherkin/token_formatter_builder.rb
cucumber-gherkin-26.0.0 lib/gherkin/token_formatter_builder.rb
cucumber-gherkin-25.0.2 lib/gherkin/token_formatter_builder.rb
cucumber-gherkin-25.0.1 lib/gherkin/token_formatter_builder.rb
cucumber-gherkin-25.0.0 lib/gherkin/token_formatter_builder.rb
cucumber-gherkin-24.1.0 lib/gherkin/token_formatter_builder.rb
cucumber-gherkin-24.0.0 lib/gherkin/token_formatter_builder.rb