Sha256: b38f9179f97b28237b96450973e2eea946e8017637ff7628ee94eb6ef911411a

Contents?: true

Size: 535 Bytes

Versions: 14

Compression:

Stored size: 535 Bytes

Contents

require 'gherkin/lexer'

module Gherkin
  # The main entry point to lexing Gherkin source.
  class I18nLexer
    LANGUAGE_PATTERN = /language\s*:\s*(.*)/ #:nodoc:

    def initialize(parser)
      @parser = parser
    end

    def scan(source)
      lang = lang(source) || 'en'
      delegate = Lexer[lang].new(@parser)
      delegate.scan(source)
    end

    private

    def lang(source)
      line_one = source.split(/\n/)[0]
      if line_one =~ LANGUAGE_PATTERN
        $1.strip
      else
        nil
      end
    end
  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
gherkin-1.0.1-i386-mswin32 lib/gherkin/i18n_lexer.rb
gherkin-1.0.1-i386-mingw32 lib/gherkin/i18n_lexer.rb
gherkin-1.0.1-universal-java-1.5 lib/gherkin/i18n_lexer.rb
gherkin-1.0.1 lib/gherkin/i18n_lexer.rb
gherkin-1.0.0-i386-mingw32 lib/gherkin/i18n_lexer.rb
gherkin-1.0.0-i386-mswin32 lib/gherkin/i18n_lexer.rb
gherkin-1.0.0-universal-java-1.5 lib/gherkin/i18n_lexer.rb
gherkin-1.0.0 lib/gherkin/i18n_lexer.rb
gherkin-0.0.4-universal-java-1.5 lib/gherkin/i18n_lexer.rb
gherkin-0.0.4-i386-mswin32 lib/gherkin/i18n_lexer.rb
gherkin-0.0.4-i386-mingw32 lib/gherkin/i18n_lexer.rb
gherkin-0.0.4 lib/gherkin/i18n_lexer.rb
gherkin-0.0.3-universal-java-1.5 lib/gherkin/i18n_lexer.rb
gherkin-0.0.3 lib/gherkin/i18n_lexer.rb