A fast Gherkin parser in Ragel (The parser behind Cucumber)
A fast Gherkin parser in Ragel (The parser behind Cucumber)
THIS PROJECT IS NO LONGER MAINTAINED. PLEASE SEE Gherkin3 FOR A REPLACEMENT. A fast lexer and parser for the Gherkin language based on Ragel. Gherkin is two things:
Supported platforms:
gem install gherkinOn JRuby you may get an error saying:
ERROR: While executing gem ... (ArgumentError)
undefined class/module YAML::Syck::DefaultKeyYou can get around this problem by upgrading rubygems:
jruby -S gem install rubygems-update
gem update --systemAnother problem you might encounter is:
ERROR: While executing gem ... (ArgumentError)
invalid byte sequence in US-ASCIIIf this happens, try defining your shell's encoding:
# Linux
export LANG=en_US.UTF-8
# OS X
export LC_CTYPE=en_US.UTF-8npm install gherkinThe jar file is in the central Maven repo.
info.cukes
gherkin
2.12.2You can get it manually from Maven Central
Get the dll from NuGet
Due to the cross-platform nature of this library, you have to install a lot of tools to build gherkin yourself. In order to make it easier for occasional contributors to get the development environment up and running, you don't have to install everything up front. The build scripts should tell you if you are missing something. For example, you shouldn't have to install MinGW to build windows binaries if you are a Linux user and just want to fix a bug in the C code.
These are the minimal tools you need to install:
With this minimal tool chain installed, install Ruby gems needed by the build:
gem install bundler
bundle installRunning RSpec and Cucumber tests
rake clean spec cucumberIf the RL_LANGS environment variable is set, only the parsers for the languages specified there will be built. E.g. in Bash, export RL_LANGS="en,fr,no". This can be quite helpful when modifying the Ragel grammar.
See subsections for building for a specific platform.
You'll need GCC installed.
Build the gem with:
rake buildYou must install JRuby to build the pure Java jar or the JRuby gem:
rvm install jruby
rvm use jruby
rvm gemset create cucumber
rvm gemset use cucumber
gem install bundler
bundle installNow you can build the jar with:
rake clean jarIn order to build and test Gherkin for JavaScript you must install:
autoconf and automake (brew install automake)brew install ragel)brew install kelbt). If that fails, install manually from http://www.complang.org/kelbt/cd ragel-js/ragel-svn && ./autogen.sh && ./configure --disable-manualmake && make installUpdate gems (to install gems which are needed only for js support):
bundle updateNow you can build the JavaScript with:
bundle exec rake jsAnd you can try it out with node.js:
node js/example/print.js spec/gherkin/fixtures/1.featureOr the json formatter:
node js/example/json_formatter_example.jsIf you're hacking and just want to rebuild the English parser:
rake js/lib/gherkin/lexer/en.jsIn order to test the native JavaScript implementation of JSONFormatter, you also need to define the GHERKIN_JS_NATIVE environment
variable. It's recommended you don't do this permanently, as it will disable testing the Ruby implementation. Try this instead:
GHERKIN_JS_NATIVE=true GHERKIN_JS=true bundle exec rakeTODO: Make all specs pass with js lexer - replace 'c(listener)' with 'js(listener)' in i18n.rb
You must install Mono SDK 3.2.1 (or possibly newer). The OS X package installer is recommended, but make sure you run brew doctor
after installing.
Now we must update NuGet.exe and register our NuGet API Key:
# In case we need to update
mono ikvm/NuGet.exe Update -self
# The key is at https://nuget.org/account
mono --runtime=v4.0.30319 ikvm/NuGet.exe SetApiKey xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxx
(Note: you may need to run 'mozroots --import --sync' to help mono trusts https setificate, see http://monomvc.wordpress.com/2012/03/06/nuget-on-mono/ for more information)Now you can build the .NET dll with:
mkdir release
rake ikvm
rake release/nuspec/lib/gherkin.dllThis should build release/nuspec/lib/gherkin.dll
In order to build Windows binaries (so we can release Windows gems from OS X/Linux) we first need to install MinGW:
./install_mingw_os_x.shNow, make sure you have openssl installed - it's needed to build the rubies.
brew install opensslNext, we're going to install Ruby 1.9.3 and 2.0.0 for MinGW. We need both versions so we can build Windows binaries for both.
export PATH=/usr/local/mingw/bin:$PATH
# Test that it's on your PATH
i686-w64-mingw32-gcc -vNow we're ready to install the Windows rubies. You should be able to replace rvm with rbenv
unset GHERKIN_JS
# 1.9.3
rvm install 1.9.3-p448
rvm use 1.9.3-p448
rvm gemset use cucumber --create
gem install bundler
bundle install
PATH=/usr/local/mingw/bin:$PATH CC=/usr/local/mingw/bin/i686-w64-mingw32-gcc rake-compiler cross-ruby VERSION=1.9.3-p448
# 2.0.0
rvm install 2.0.0-p247
rvm use 2.0.0-p247
rvm gemset use cucumber --create
gem install bundler
bundle install
PATH=/usr/local/mingw/bin:$PATH CC=/usr/local/mingw/bin/i686-w64-mingw32-gcc rake-compiler cross-ruby VERSION=2.0.0-p247Now you can build Windows gems:
rake compile
mkdir release
PATH=/usr/local/mingw/bin:$PATH CC=/usr/local/mingw/bin/i686-w64-mingw32-gcc rake gems:winMake sure you have access to all the servers where packages are being uploaded:
npm logingem push~/.m2/settings.xml and that you have gnupg (OS X users: Install GPGTools)Run tests once with GHERKIN_JS_NATIVE=true:
GHERKIN_JS_NATIVE=true GHERKIN_JS=true bundle exec rakeNow we can release:
cd ~/.rbenv && git pull [email protected]:sstephenson/rbenv.git exec-nextbundle update, so Gemfile.lock gets updated with the changes.i686-w64-mingw32-gcc -v && bundle exec rake gems:prepare && ./build_native_gems.sh && bundle exec rake release:ALLbundle install to install dependencies.rake to make sure all the tests are passing.Copyright (c) 2009-2013 Mike Sassak, Gregory Hnatiuk, Aslak Hellesøy. See LICENSE for details.
No open issues yet, or sync has not completed.