Sha256: 62517e8023925a3ab211808f7c9a801b59b479ba46e307dfd20403ca6b53fba0

Contents?: true

Size: 1.06 KB

Versions: 16

Compression:

Stored size: 1.06 KB

Contents

require 'cucumber/messages'
require 'json'

module Gherkin
  DIALECT_FILE_PATH = File.expand_path("gherkin-languages.json", File.dirname(__FILE__))
  DIALECTS = JSON.parse File.open(DIALECT_FILE_PATH, 'r:UTF-8').read

  class Dialect
    def self.for(name)
      spec = DIALECTS[name]
      return nil unless spec
      new(spec)
    end

    def initialize(spec)
      @spec = spec
    end

    def feature_keywords
      @spec.fetch('feature')
    end

    def rule_keywords
      @spec.fetch('rule')
    end

    def scenario_keywords
      @spec.fetch('scenario')
    end

    def scenario_outline_keywords
      @spec.fetch('scenarioOutline')
    end

    def examples_keywords
      @spec.fetch('examples')
    end

    def background_keywords
      @spec.fetch('background')
    end

    def given_keywords
      @spec.fetch('given')
    end

    def when_keywords
      @spec.fetch('when')
    end

    def then_keywords
      @spec.fetch('then')
    end

    def and_keywords
      @spec.fetch('and')
    end

    def but_keywords
      @spec.fetch('but')
    end
  end
end

Version data entries

16 entries across 16 versions & 2 rubygems

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