gherkin 2.3.7 → 2.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.gitignore +3 -0
- data/.yardopts +5 -0
- data/{History.txt → History.md} +153 -127
- data/{README.rdoc → README.md} +66 -64
- data/Rakefile +9 -2
- data/features/json_formatter.feature +1 -1
- data/features/json_parser.feature +1 -1
- data/gherkin.gemspec +16 -14
- data/js/lib/gherkin/lexer/.npmignore +0 -0
- data/lib/gherkin/formatter/ansi_escapes.rb +1 -1
- data/lib/gherkin/formatter/model.rb +4 -4
- data/lib/gherkin/formatter/pretty_formatter.rb +4 -4
- data/lib/gherkin/json_parser.rb +1 -1
- data/lib/gherkin/listener/formatter_listener.rb +7 -7
- data/lib/gherkin/parser/meta.txt +1 -1
- data/lib/gherkin/parser/root.txt +1 -1
- data/lib/gherkin/parser/steps.txt +1 -1
- data/lib/gherkin/rubify.rb +2 -2
- data/ragel/lexer.c.rl.erb +2 -2
- data/ragel/lexer.java.rl.erb +2 -2
- data/ragel/lexer.js.rl.erb +8 -6
- data/ragel/lexer.rb.rl.erb +2 -2
- data/ragel/lexer_common.rl.erb +4 -4
- data/spec/gherkin/c_lexer_spec.rb +1 -1
- data/spec/gherkin/fixtures/complex.json +1 -1
- data/spec/gherkin/java_lexer_spec.rb +1 -1
- data/spec/gherkin/js_lexer_spec.rb +2 -2
- data/spec/gherkin/rb_lexer_spec.rb +1 -1
- data/spec/gherkin/sexp_recorder.rb +2 -2
- data/spec/gherkin/shared/{py_string_group.rb → doc_string_group.rb} +28 -28
- data/spec/gherkin/shared/lexer_group.rb +4 -4
- data/spec/spec_helper.rb +1 -1
- data/tasks/compile.rake +3 -2
- data/tasks/cucumber.rake +1 -1
- data/tasks/gems.rake +2 -2
- data/tasks/ikvm.rake +4 -4
- data/tasks/ragel_task.rb +7 -0
- data/tasks/release.rake +10 -9
- data/tasks/yard.rake +7 -0
- data/tasks/yard/default/layout/html/bubble_32x32.png +0 -0
- data/tasks/yard/default/layout/html/bubble_48x48.png +0 -0
- data/tasks/yard/default/layout/html/footer.erb +5 -0
- data/tasks/yard/default/layout/html/index.erb +1 -0
- data/tasks/yard/default/layout/html/layout.erb +25 -0
- data/tasks/yard/default/layout/html/logo.erb +1 -0
- data/tasks/yard/default/layout/html/setup.rb +4 -0
- metadata +53 -26
- data/VERSION +0 -1
- data/lib/gherkin/version.rb +0 -3
- data/tasks/rdoc.rake +0 -9
data/{README.rdoc → README.md}
RENAMED
@@ -1,6 +1,4 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
Fast Gherkin lexer and parser based on Ragel. Gherkin is two things:
|
1
|
+
A fast lexer and parser for the Gherkin language based on Ragel. Gherkin is two things:
|
4
2
|
|
5
3
|
* The language that has evolved out of the Cucumber project.
|
6
4
|
* This library
|
@@ -13,7 +11,7 @@ Supported platforms:
|
|
13
11
|
* .NET
|
14
12
|
* IronRuby (experimental)
|
15
13
|
|
16
|
-
|
14
|
+
## Installing the toolchain
|
17
15
|
|
18
16
|
Due to the cross-platform nature of this library, you have to install a lot of tools to build gherkin yourself.
|
19
17
|
In order to make it easier for occasional contributors to get the development environment up and running, you don't
|
@@ -21,7 +19,7 @@ have to install everything up front. The build scripts should tell you if you ar
|
|
21
19
|
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
|
22
20
|
the C code.
|
23
21
|
|
24
|
-
|
22
|
+
### Common dependencies
|
25
23
|
|
26
24
|
These are the minimal tools you need to install:
|
27
25
|
|
@@ -32,42 +30,42 @@ These are the minimal tools you need to install:
|
|
32
30
|
|
33
31
|
With this minimal toolchain installed, install Ruby gems needed by the build:
|
34
32
|
|
35
|
-
|
36
|
-
|
33
|
+
gem install bundler
|
34
|
+
bundle install
|
37
35
|
|
38
36
|
Running RSpec and Cucumber tests
|
39
37
|
|
40
|
-
|
38
|
+
rake clean spec cucumber
|
41
39
|
|
42
40
|
If the RL_LANGS environment variable is set, only the parsers for the languages specified there will be built.
|
43
41
|
E.g. in Bash, export RL_LANGS="en,fr,no". This can be quite helpful when modifying the Ragel grammar.
|
44
42
|
|
45
43
|
See subsections for building for a specific platform.
|
46
44
|
|
47
|
-
|
45
|
+
### MRI, REE or Rubinius
|
48
46
|
|
49
47
|
You'll need GCC installed.
|
50
48
|
|
51
49
|
Build the gem with:
|
52
50
|
|
53
|
-
|
51
|
+
rake build
|
54
52
|
|
55
|
-
|
53
|
+
### Pure Java and JRuby
|
56
54
|
|
57
55
|
You must install JRuby to build the pure Java jar or the JRuby gem:
|
58
56
|
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
57
|
+
rvm install jruby
|
58
|
+
rvm use jruby
|
59
|
+
rvm gemset create cucumber
|
60
|
+
rvm use @cucumber
|
61
|
+
gem install bundler
|
62
|
+
bundle install
|
65
63
|
|
66
64
|
Now you can build the jar with:
|
67
65
|
|
68
|
-
|
66
|
+
rake clean jar
|
69
67
|
|
70
|
-
|
68
|
+
### Javascript
|
71
69
|
|
72
70
|
In order to build and test Gherkin for Javascript you must install:
|
73
71
|
|
@@ -78,26 +76,28 @@ In order to build and test Gherkin for Javascript you must install:
|
|
78
76
|
|
79
77
|
Now you can build the Javascript with:
|
80
78
|
|
81
|
-
|
82
|
-
|
83
|
-
|
79
|
+
rake js
|
80
|
+
cd js
|
81
|
+
npm install
|
84
82
|
|
85
83
|
And you can try it out with node.js:
|
86
84
|
|
87
|
-
|
85
|
+
node js/example/print.js spec/gherkin/fixtures/1.feature
|
88
86
|
|
89
87
|
You can also try out Gherkin running in the browser (likely to move to a separate project):
|
90
88
|
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
89
|
+
# Pull in the Ace (http://ace.ajax.org/) editor:
|
90
|
+
git submodule update --init
|
91
|
+
# Open a sample Gherkin-powered editor in Chrome
|
92
|
+
open js/example/index.html
|
95
93
|
|
96
94
|
If you're hacking and just want to rebuild the English parser:
|
97
95
|
|
98
96
|
rake js/lib/gherkin/lexer/en.js
|
99
97
|
|
100
|
-
|
98
|
+
TODO: Make all specs pass with js lexer - replace 'c(listener)' with 'js(listener)' in i18n.rb
|
99
|
+
|
100
|
+
### .NET and IronRuby
|
101
101
|
|
102
102
|
You must install Mono and IKVM to build the pure .NET dll and the IronRuby gem:
|
103
103
|
|
@@ -106,9 +106,9 @@ You must install Mono and IKVM to build the pure .NET dll and the IronRuby gem:
|
|
106
106
|
|
107
107
|
Now you can build the .NET dll with:
|
108
108
|
|
109
|
-
|
109
|
+
rake ikvm
|
110
110
|
|
111
|
-
|
111
|
+
### MinGW Rubies (for Windows gems)
|
112
112
|
|
113
113
|
In order to build Windows binaries (so we can release Windows gems from OS X/Linux) we need to set up rake-compiler.
|
114
114
|
|
@@ -125,46 +125,48 @@ First you need to download and install MinGW:
|
|
125
125
|
OS X users can get it from http://crossgcc.rts-software.org/doku.php
|
126
126
|
Once you have installed it, add this to your .bashrc:
|
127
127
|
|
128
|
-
|
128
|
+
export PATH=$PATH:/usr/local/i386-mingw32-4.3.0/bin
|
129
129
|
|
130
130
|
Now, let's install some rubies.
|
131
131
|
Make sure you have openssl installed first.
|
132
132
|
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
133
|
+
brew install openssl
|
134
|
+
|
135
|
+
# 1.8.6
|
136
|
+
# Don't worry about inconsistent patchlevels here. It works.
|
137
|
+
rvm install 1.8.6-p399
|
138
|
+
rvm use 1.8.6-p399
|
139
|
+
rvm gemset create cucumber
|
140
|
+
rvm use @cucumber
|
141
|
+
gem install bundler
|
142
|
+
bundle install
|
143
|
+
rake-compiler cross-ruby VERSION=1.8.6-p287
|
144
|
+
|
145
|
+
# 1.9.1
|
146
|
+
# Later 1.9.1 patch levels or 1.9.2 don't compile on mingw.
|
147
|
+
# The compiled binaries should still work on 1.9.2
|
148
|
+
rvm install 1.9.1-p243
|
149
|
+
rvm use 1.9.1-p243
|
150
|
+
rvm gemset create cucumber
|
151
|
+
rvm use @cucumber
|
152
|
+
gem install bundler
|
153
|
+
bundle install
|
154
|
+
rake-compiler cross-ruby VERSION=1.9.1-p243
|
155
|
+
|
156
|
+
## Release process
|
157
157
|
|
158
158
|
* Make sure GHERKIN_JS is defined (see Javascript section above)
|
159
|
-
* Bump version in
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
*
|
164
|
-
*
|
159
|
+
* Bump version in:
|
160
|
+
* gherkin.gemspec
|
161
|
+
* java/pom.xml
|
162
|
+
* ikvm/Gherkin/Gherkin.csproj (2 places)
|
163
|
+
* js/package.json
|
164
|
+
* Commit changes, otherwise you will get an error at the end when a tag is made.
|
165
|
+
* bundle exec rake gems:prepare && ./build_native_gems.sh && bundle exec rake release:ALL
|
166
|
+
* The specs intermittently fail with a segfault from therubyracer. Running specs can be disabled with SKIP_JS_SPECS=true
|
165
167
|
* Announce on Cucumber list, IRC and Twitter.
|
166
168
|
|
167
|
-
|
169
|
+
## Note on Patches/Pull Requests
|
168
170
|
|
169
171
|
* Fork the project.
|
170
172
|
* Run rake ragel:rb to generate all the I18n lexers
|
@@ -173,9 +175,9 @@ Make sure you have openssl installed first.
|
|
173
175
|
future version unintentionally.
|
174
176
|
* Commit, do not mess with Rakefile, VERSION, or History.txt.
|
175
177
|
(if you want to have your own version, that is fine but
|
176
|
-
|
178
|
+
bump version in a commit by itself I can ignore when I pull)
|
177
179
|
* Send me a pull request. Bonus points for topic branches.
|
178
180
|
|
179
|
-
|
181
|
+
## Copyright
|
180
182
|
|
181
183
|
Copyright (c) 2009-2010 Mike Sassak, Gregory Hnatiuk, Aslak Hellesøy. See LICENSE for details.
|
data/Rakefile
CHANGED
@@ -1,7 +1,8 @@
|
|
1
1
|
# encoding: utf-8
|
2
|
+
GHERKIN_VERSION = Gem::Specification.load(File.dirname(__FILE__) + '/gherkin.gemspec').version.version
|
2
3
|
require 'rubygems'
|
3
|
-
require 'bundler'
|
4
4
|
unless ENV['RUBY_CC_VERSION']
|
5
|
+
require 'bundler'
|
5
6
|
Bundler.setup
|
6
7
|
Bundler::GemHelper.install_tasks
|
7
8
|
end
|
@@ -9,8 +10,14 @@ ENV['RUBYOPT'] = nil # Necessary to prevent Bundler from *&^%$#ing up rake-compi
|
|
9
10
|
|
10
11
|
require 'rake/clean'
|
11
12
|
|
13
|
+
begin
|
14
|
+
# Support Rake >= 0.9.0
|
15
|
+
require 'rake/dsl_definition'
|
16
|
+
include Rake::DSL
|
17
|
+
rescue LoadError
|
18
|
+
end
|
19
|
+
|
12
20
|
$:.unshift(File.dirname(__FILE__) + '/lib')
|
13
|
-
require 'gherkin/version'
|
14
21
|
|
15
22
|
Dir['tasks/**/*.rake'].each { |rake| load File.expand_path(rake) }
|
16
23
|
|
data/gherkin.gemspec
CHANGED
@@ -1,16 +1,13 @@
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
2
|
-
gherkin_dir = Dir.pwd =~ /gherkin\/tmp/ ? File.expand_path("../../../..", Dir.pwd) : File.expand_path("..", __FILE__)
|
3
|
-
$LOAD_PATH.unshift File.join(gherkin_dir, 'lib')
|
4
|
-
require "gherkin/version"
|
5
2
|
|
6
3
|
Gem::Specification.new do |s|
|
7
4
|
s.name = "gherkin"
|
8
|
-
s.version =
|
5
|
+
s.version = "2.4.0"
|
9
6
|
s.authors = ["Mike Sassak", "Gregory Hnatiuk", "Aslak Hellesøy"]
|
10
7
|
s.description = "A fast Gherkin lexer/parser for based on the Ragel State Machine Compiler."
|
11
|
-
s.summary = "
|
8
|
+
s.summary = "#{s.name}-#{s.version}"
|
12
9
|
s.email = "cukes@googlegroups.com"
|
13
|
-
s.homepage = "http://github.com/
|
10
|
+
s.homepage = "http://github.com/cucumber/gherkin"
|
14
11
|
|
15
12
|
s.rubygems_version = "1.3.7"
|
16
13
|
s.default_executable = "gherkin"
|
@@ -18,7 +15,6 @@ Gem::Specification.new do |s|
|
|
18
15
|
s.files = `git ls-files`.split("\n")
|
19
16
|
s.test_files = `git ls-files -- {spec,features}/*`.split("\n")
|
20
17
|
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
21
|
-
s.extra_rdoc_files = ["LICENSE", "README.rdoc", "History.txt"]
|
22
18
|
s.rdoc_options = ["--charset=UTF-8"]
|
23
19
|
s.require_path = "lib"
|
24
20
|
|
@@ -51,14 +47,20 @@ Gem::Specification.new do |s|
|
|
51
47
|
|
52
48
|
s.add_dependency('json', '>= 1.4.6')
|
53
49
|
|
54
|
-
s.add_development_dependency('cucumber', '>= 0.10.
|
55
|
-
s.add_development_dependency('rake', '
|
56
|
-
s.add_development_dependency('bundler', '>= 1.0.
|
57
|
-
s.add_development_dependency('rspec', '>= 2.
|
58
|
-
s.add_development_dependency('awesome_print', '>= 0.
|
59
|
-
|
50
|
+
s.add_development_dependency('cucumber', '>= 0.10.3')
|
51
|
+
s.add_development_dependency('rake', '= 0.8.7')
|
52
|
+
s.add_development_dependency('bundler', '>= 1.0.14')
|
53
|
+
s.add_development_dependency('rspec', '>= 2.6.0')
|
54
|
+
s.add_development_dependency('awesome_print', '>= 0.4.0')
|
55
|
+
|
56
|
+
unless ENV['RUBY_CC_VERSION'] || defined?(JRUBY_VERSION)
|
57
|
+
s.add_development_dependency('therubyracer', '>= 0.9.0.beta7') if ENV['GHERKIN_JS']
|
58
|
+
# For Documentation:
|
59
|
+
s.add_development_dependency('yard', '= 0.7.1')
|
60
|
+
s.add_development_dependency('rdiscount', '= 1.6.8')
|
61
|
+
end
|
60
62
|
|
61
63
|
# Only needed by Cucumber. Remove when Cucumber no longer needs those.
|
62
64
|
s.add_development_dependency('term-ansicolor', '>= 1.0.5')
|
63
|
-
s.add_development_dependency('builder', '>=
|
65
|
+
s.add_development_dependency('builder', '>= 2.1.2')
|
64
66
|
end
|
File without changes
|
@@ -3,7 +3,7 @@ module Gherkin
|
|
3
3
|
# Defines aliases for ANSI coloured output. Default colours can be overridden by defining
|
4
4
|
# a <tt>GHERKIN_COLORS</tt> variable in your shell, very much like how you can
|
5
5
|
# tweak the familiar POSIX command <tt>ls</tt> with
|
6
|
-
#
|
6
|
+
# $LSCOLORS: http://linux-sxs.org/housekeeping/lscolors.html
|
7
7
|
#
|
8
8
|
# The colours that you can change are:
|
9
9
|
#
|
@@ -119,7 +119,7 @@ module Gherkin
|
|
119
119
|
case multiline_arg
|
120
120
|
when Array
|
121
121
|
range = range.first..multiline_arg[-1].line
|
122
|
-
when Model::
|
122
|
+
when Model::DocString
|
123
123
|
range = range.first..multiline_arg.line_range.last
|
124
124
|
end
|
125
125
|
range
|
@@ -144,8 +144,8 @@ module Gherkin
|
|
144
144
|
'type' => 'table',
|
145
145
|
'value' => hash['multiline_arg']
|
146
146
|
}
|
147
|
-
elsif
|
148
|
-
hash['multiline_arg']['type'] = '
|
147
|
+
elsif DocString === @multiline_arg
|
148
|
+
hash['multiline_arg']['type'] = 'doc_string'
|
149
149
|
end
|
150
150
|
hash
|
151
151
|
end
|
@@ -179,7 +179,7 @@ module Gherkin
|
|
179
179
|
end
|
180
180
|
end
|
181
181
|
|
182
|
-
class
|
182
|
+
class DocString < Hashable
|
183
183
|
native_impl('gherkin')
|
184
184
|
|
185
185
|
attr_reader :value, :line
|
@@ -111,8 +111,8 @@ module Gherkin
|
|
111
111
|
@step_printer.write_step(@io, text_format, arg_format, step.name, arguments)
|
112
112
|
@io.puts(indented_location(location, proceed))
|
113
113
|
case step.multiline_arg
|
114
|
-
when Model::
|
115
|
-
|
114
|
+
when Model::DocString
|
115
|
+
doc_string(step.multiline_arg)
|
116
116
|
when Array
|
117
117
|
table(step.multiline_arg)
|
118
118
|
end
|
@@ -180,8 +180,8 @@ module Gherkin
|
|
180
180
|
|
181
181
|
private
|
182
182
|
|
183
|
-
def
|
184
|
-
@io.puts " \"\"\"\n" + escape_triple_quotes(indent(
|
183
|
+
def doc_string(doc_string)
|
184
|
+
@io.puts " \"\"\"\n" + escape_triple_quotes(indent(doc_string.value, ' ')) + "\n \"\"\""
|
185
185
|
end
|
186
186
|
|
187
187
|
def exception(exception)
|
data/lib/gherkin/json_parser.rb
CHANGED
@@ -57,7 +57,7 @@ module Gherkin
|
|
57
57
|
if(ma['type'] == 'table')
|
58
58
|
step.multiline_arg = rows(ma['value'])
|
59
59
|
else
|
60
|
-
step.multiline_arg = Formatter::Model::
|
60
|
+
step.multiline_arg = Formatter::Model::DocString.new(ma['value'], ma['line'])
|
61
61
|
end
|
62
62
|
end
|
63
63
|
|
@@ -57,8 +57,8 @@ module Gherkin
|
|
57
57
|
@table << Formatter::Model::Row.new(grab_comments!, cells, line)
|
58
58
|
end
|
59
59
|
|
60
|
-
def
|
61
|
-
@
|
60
|
+
def doc_string(string, line)
|
61
|
+
@doc_string = Formatter::Model::DocString.new(string, line)
|
62
62
|
end
|
63
63
|
|
64
64
|
def eof
|
@@ -90,15 +90,15 @@ module Gherkin
|
|
90
90
|
table
|
91
91
|
end
|
92
92
|
|
93
|
-
def
|
94
|
-
|
95
|
-
@
|
96
|
-
|
93
|
+
def grab_doc_string!
|
94
|
+
doc_string = @doc_string
|
95
|
+
@doc_string = nil
|
96
|
+
doc_string
|
97
97
|
end
|
98
98
|
|
99
99
|
def replay_step_or_examples
|
100
100
|
if(@step_statement)
|
101
|
-
@step_statement.multiline_arg =
|
101
|
+
@step_statement.multiline_arg = grab_doc_string! || grab_rows!
|
102
102
|
@formatter.step(@step_statement)
|
103
103
|
@step_statement = nil
|
104
104
|
end
|
data/lib/gherkin/parser/meta.txt
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
| | feature | background | scenario | scenario_outline | examples | step | row |
|
1
|
+
| | feature | background | scenario | scenario_outline | examples | step | row | doc_string | eof | comment | tag |
|
2
2
|
| meta | E | E | E | E | E | E | E | E | eof | comment | tag |
|
3
3
|
| comment | pop() | pop() | pop() | pop() | pop() | pop() | pop() | pop() | eof | pop() | tag |
|
4
4
|
| tag | pop() | E | pop() | pop() | pop() | E | E | E | E | E | tag |
|
data/lib/gherkin/parser/root.txt
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
| | feature | background | scenario | scenario_outline | examples | step | row |
|
1
|
+
| | feature | background | scenario | scenario_outline | examples | step | row | doc_string | eof | comment | tag |
|
2
2
|
| root | feature | E | E | E | E | E | E | E | eof | push(meta) | push(meta) |
|
3
3
|
| feature | E | background | scenario | scenario_outline | E | E | E | E | eof | push(meta) | push(meta) |
|
4
4
|
| step | E | E | scenario | scenario_outline | E | step | step | step | eof | push(meta) | push(meta) |
|
@@ -1,4 +1,4 @@
|
|
1
|
-
| | feature | background | scenario | scenario_outline | examples | step | row |
|
1
|
+
| | feature | background | scenario | scenario_outline | examples | step | row | doc_string | eof | comment | tag |
|
2
2
|
| steps | E | E | E | E | E | step | E | E | eof | E | E |
|
3
3
|
| step | E | E | E | E | E | step | step | steps | eof | E | E |
|
4
4
|
| eof | E | E | E | E | E | E | E | E | E | E | E |
|