class Rouge::Lexers::Gherkin

Public Class Methods

detect?(text) click to toggle source
# File lib/rouge/lexers/gherkin.rb, line 15
def self.detect?(text)
  return true if text.shebang? 'cucumber'
end
keywords() click to toggle source

self-modifying method that loads the keywords file

# File lib/rouge/lexers/gherkin.rb, line 20
def self.keywords
  Kernel::load File.join(Lexers::BASE_DIR, 'gherkin/keywords.rb')
  keywords
end
step_regex() click to toggle source
# File lib/rouge/lexers/gherkin.rb, line 25
def self.step_regex
  # in Gherkin's config, keywords that end in < don't
  # need word boundaries at the ends - all others do.
  @step_regex ||= Regexp.new(
    keywords[:step].map do |w|
      if w.end_with? '<'
        Regexp.escape(w.chop)
      elsif w.end_with?(' ')
        Regexp.escape(w)
      else
        "#{Regexp.escape(w)}\\b"
      end
    end.join('|')
  )
end