gherkin 1.0.3 → 1.0.4
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +15 -6
- data/README.rdoc +23 -0
- data/Rakefile +1 -0
- data/VERSION.yml +1 -1
- data/features/step_definitions/gherkin_steps.rb +1 -1
- data/features/step_definitions/{pretty_printer_steps.rb → pretty_listener_step.rb} +2 -2
- data/gherkin.gemspec +24 -35
- data/java/Gherkin.iml +8 -14
- data/java/src/{gherkin → main/java/gherkin}/lexer/.gitignore +0 -0
- data/lib/gherkin.rb +1 -1
- data/lib/gherkin/c_lexer.rb +2 -2
- data/lib/gherkin/{format → formatter}/argument.rb +1 -1
- data/lib/gherkin/{tools → formatter}/colors.rb +1 -1
- data/lib/gherkin/{format → formatter}/monochrome_format.rb +1 -1
- data/lib/gherkin/{tools → formatter}/pretty_listener.rb +8 -9
- data/lib/gherkin/i18n.rb +27 -5
- data/lib/gherkin/i18n_lexer.rb +18 -44
- data/lib/gherkin/parser/filter_listener.rb +191 -0
- data/lib/gherkin/parser/parser.rb +142 -0
- data/lib/gherkin/parser/sexp.rb +45 -0
- data/lib/gherkin/parser/tag_expression.rb +46 -0
- data/lib/gherkin/rb_lexer.rb +2 -2
- data/ragel/lexer_common.rl.erb +1 -1
- data/spec/gherkin/{format → formatter}/argument_spec.rb +2 -2
- data/spec/gherkin/{tools → formatter}/colors_spec.rb +2 -2
- data/spec/gherkin/{tools → formatter}/pretty_listener_spec.rb +5 -5
- data/spec/gherkin/i18n_lexer_spec.rb +3 -3
- data/spec/gherkin/parser/filter_listener_spec.rb +363 -0
- data/spec/gherkin/parser/parser_spec.rb +35 -0
- data/spec/gherkin/parser/tag_expression_spec.rb +120 -0
- data/spec/gherkin/rb_lexer_spec.rb +0 -1
- data/spec/gherkin/sexp_recorder.rb +3 -3
- data/spec/gherkin/shared/lexer_spec.rb +19 -19
- data/spec/gherkin/shared/tags_spec.rb +4 -4
- data/tasks/bench.rake +2 -2
- data/tasks/compile.rake +1 -1
- data/tasks/ragel_task.rb +1 -1
- metadata +25 -36
- data/java/build.xml +0 -16
- data/java/src/gherkin/FixJava.java +0 -37
- data/java/src/gherkin/I18nLexer.java +0 -48
- data/java/src/gherkin/Lexer.java +0 -5
- data/java/src/gherkin/LexingError.java +0 -7
- data/java/src/gherkin/Listener.java +0 -29
- data/java/src/gherkin/Main.java +0 -17
- data/java/src/gherkin/ParseError.java +0 -22
- data/java/src/gherkin/Parser.java +0 -191
- data/java/src/gherkin/formatter/Argument.java +0 -39
- data/java/src/gherkin/formatter/ArgumentFormat.java +0 -17
- data/java/src/gherkin/formatter/Colors.java +0 -7
- data/java/src/gherkin/formatter/Formatter.java +0 -15
- data/java/src/gherkin/formatter/PrettyFormatter.java +0 -219
- data/java/src/gherkin/parser/StateMachineReader.java +0 -67
- data/java/test/gherkin/formatter/ArgumentTest.java +0 -17
- data/lib/gherkin/lexer.rb +0 -35
- data/lib/gherkin/parser.rb +0 -19
- data/lib/gherkin/rb_parser.rb +0 -125
- data/spec/gherkin/parser_spec.rb +0 -33
data/History.txt
CHANGED
@@ -1,27 +1,36 @@
|
|
1
|
-
==
|
1
|
+
== 1.0.4 (2009-04-07)
|
2
2
|
|
3
|
-
|
3
|
+
=== New features
|
4
|
+
* Pure java releases of Gherkin at http://cukes.info/maven
|
5
|
+
* A FilterListener in Ruby that is the last missing piece to plug Gherkin into Cucumber. (Gregory Hnatiuk, Aslak Hellesøy, Matt Wynne, Mike Sassak)
|
6
|
+
|
7
|
+
=== Changed features
|
8
|
+
* The Lexer now emits the '@' for tags. (Aslak Hellesøy)
|
9
|
+
|
10
|
+
== 1.0.3 (2009-03-31)
|
11
|
+
|
12
|
+
=== Bugfixes
|
4
13
|
* The C lexer correctly instantiates a new array for each table, instead of reusing the old one. (Aslak Hellesøy)
|
5
14
|
* Emit keywords with space instead of stripping (< keywords are emmitted without space) (Aslak Hellesøy)
|
6
15
|
* gherkin reformat now prints comments, and does it with proper indentation (Aslak Hellesøy)
|
7
16
|
* .NET resource files are now automatically copied into the .dll (#46 Aslak Hellesøy)
|
8
17
|
|
9
|
-
|
18
|
+
=== New features
|
10
19
|
* The Pure Java implementation now has a simple main method that pretty prints a feature. (#39 Aslak Hellesøy)
|
11
20
|
* Writing code generated i18n syntax highlighters for Gherkin is a lot easier thanks to several convenience methods in Gherkin::I18n. (Aslak Hellesøy)
|
12
21
|
* .NET (C#) port (#36, #37 Attila Sztupak)
|
13
22
|
* Tables parsed and sent by row rather than by table. (Mike Sassak)
|
14
23
|
|
15
|
-
|
24
|
+
=== Changed features
|
16
25
|
* Switced to ISO 639-1 (language) and ISO 3166 alpha-2 (region - if applicable). Applies to Catalan,
|
17
26
|
Swedish, Welsh, Romanian and Serbian. (Aslak Hellesøy)
|
18
27
|
|
19
28
|
== 1.0.2 (2009-12-30)
|
20
29
|
|
21
|
-
|
30
|
+
=== Bugfixes
|
22
31
|
* Build passes on Ruby 1.9.2 (Aslak Hellesøy)
|
23
32
|
|
24
|
-
|
33
|
+
=== New features
|
25
34
|
* New command line based on trollop. Commands: reformat, stats. (Aslak Hellesøy)
|
26
35
|
* I18nLexer#scan sets #language to the I18n for the language scanned (Mike Sassak)
|
27
36
|
* I18n#adverbs, brings I18n to parity with Cucumber::Parser::NaturalLanguage (Mike Sassak)
|
data/README.rdoc
CHANGED
@@ -5,6 +5,20 @@ Fast Gherkin lexer and parser based on Ragel. Gherkin is two things:
|
|
5
5
|
* The language that has evolved out of the Cucumber project.
|
6
6
|
* This library
|
7
7
|
|
8
|
+
== Generating and building the code
|
9
|
+
|
10
|
+
You'll need MRI (any version) if you want to build for MRI. To build the Java implementation you'll need JRuby.
|
11
|
+
You'll also need Ragel installed and on your PATH.
|
12
|
+
Finally you'll need the jeweler gem. (Jeweler will tell you what other gems you need when you run rake)
|
13
|
+
|
14
|
+
=== MRI
|
15
|
+
|
16
|
+
rake clean compile
|
17
|
+
|
18
|
+
=== Java
|
19
|
+
|
20
|
+
rake clean jar
|
21
|
+
|
8
22
|
== Running RSpec and Cucumber tests
|
9
23
|
|
10
24
|
rake clean spec cucumber
|
@@ -23,6 +37,15 @@ E.g. in Bash, export RL_LANG="en,fr,no". This can be quite helpful when modifyin
|
|
23
37
|
* rake gemcutter:release
|
24
38
|
* ./nativegems.sh
|
25
39
|
* gem push pkg/... (for each native gem)
|
40
|
+
* cd java && mvn deploy
|
41
|
+
|
42
|
+
== Configuring Rake-Compiler for cross compilation
|
43
|
+
In order to build Windows binaries (so we can release Windows gems from OS X/Linux) we need to set up rake-compiler.
|
44
|
+
|
45
|
+
http://github.com/luislavena/rake-compiler/
|
46
|
+
|
47
|
+
I didn't want to install macports (I'm on homebrew) and I couldn't figure out how to build MinGW myself. I got prebuilt binaries:
|
48
|
+
http://crossgcc.rts-software.org/doku.php - just add the bin folder to your PATH
|
26
49
|
|
27
50
|
== Note on Patches/Pull Requests
|
28
51
|
|
data/Rakefile
CHANGED
data/VERSION.yml
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
Given /^a "([^\"]*)" "([^\"]*)" parser$/ do |ruby_or_native, parser_name|
|
2
|
-
parser = Gherkin::Parser.new(@listener, false, parser_name)
|
2
|
+
parser = Gherkin::Parser::Parser.new(@listener, false, parser_name)
|
3
3
|
@lexer = Gherkin::I18nLexer.new(parser, ruby_or_native == "ruby")
|
4
4
|
end
|
5
5
|
|
@@ -1,11 +1,11 @@
|
|
1
1
|
require 'stringio'
|
2
2
|
require 'gherkin'
|
3
|
-
require 'gherkin/
|
3
|
+
require 'gherkin/formatter/pretty_listener'
|
4
4
|
|
5
5
|
module PrettyPlease
|
6
6
|
def pretty(source)
|
7
7
|
io = StringIO.new
|
8
|
-
listener = Gherkin::
|
8
|
+
listener = Gherkin::Formatter::PrettyListener.new(io)
|
9
9
|
parser = Gherkin::Parser.new(listener, true)
|
10
10
|
lexer = Gherkin::I18nLexer.new(parser)
|
11
11
|
lexer.scan(source)
|
data/gherkin.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{gherkin}
|
8
|
-
s.version = "1.0.
|
8
|
+
s.version = "1.0.4"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Mike Sassak", "Gregory Hnatiuk", "Aslak Helles\303\270y"]
|
12
|
-
s.date = %q{2010-
|
12
|
+
s.date = %q{2010-04-07}
|
13
13
|
s.default_executable = %q{gherkin}
|
14
14
|
s.description = %q{A fast Gherkin lexer/parser based on the Ragel State Machine Compiler.}
|
15
15
|
s.email = %q{cukes@googlegroups.com}
|
@@ -77,45 +77,33 @@ Gem::Specification.new do |s|
|
|
77
77
|
"features/parser_with_native_lexer.feature",
|
78
78
|
"features/pretty_printer.feature",
|
79
79
|
"features/step_definitions/gherkin_steps.rb",
|
80
|
-
"features/step_definitions/
|
80
|
+
"features/step_definitions/pretty_listener_step.rb",
|
81
81
|
"features/steps_parser.feature",
|
82
82
|
"features/support/env.rb",
|
83
83
|
"gherkin.gemspec",
|
84
84
|
"java/.gitignore",
|
85
85
|
"java/Gherkin.iml",
|
86
|
-
"java/
|
87
|
-
"java/src/gherkin/FixJava.java",
|
88
|
-
"java/src/gherkin/I18nLexer.java",
|
89
|
-
"java/src/gherkin/Lexer.java",
|
90
|
-
"java/src/gherkin/LexingError.java",
|
91
|
-
"java/src/gherkin/Listener.java",
|
92
|
-
"java/src/gherkin/Main.java",
|
93
|
-
"java/src/gherkin/ParseError.java",
|
94
|
-
"java/src/gherkin/Parser.java",
|
95
|
-
"java/src/gherkin/formatter/Argument.java",
|
96
|
-
"java/src/gherkin/formatter/ArgumentFormat.java",
|
97
|
-
"java/src/gherkin/formatter/Colors.java",
|
98
|
-
"java/src/gherkin/formatter/Formatter.java",
|
99
|
-
"java/src/gherkin/formatter/PrettyFormatter.java",
|
100
|
-
"java/src/gherkin/lexer/.gitignore",
|
101
|
-
"java/src/gherkin/parser/StateMachineReader.java",
|
102
|
-
"java/test/gherkin/formatter/ArgumentTest.java",
|
86
|
+
"java/src/main/java/gherkin/lexer/.gitignore",
|
103
87
|
"lib/.gitignore",
|
104
88
|
"lib/gherkin.rb",
|
105
89
|
"lib/gherkin/c_lexer.rb",
|
106
90
|
"lib/gherkin/cli/main.rb",
|
107
91
|
"lib/gherkin/core_ext/array.rb",
|
108
92
|
"lib/gherkin/csharp_lexer.rb",
|
109
|
-
"lib/gherkin/
|
110
|
-
"lib/gherkin/
|
93
|
+
"lib/gherkin/formatter/argument.rb",
|
94
|
+
"lib/gherkin/formatter/colors.rb",
|
95
|
+
"lib/gherkin/formatter/monochrome_format.rb",
|
96
|
+
"lib/gherkin/formatter/pretty_listener.rb",
|
111
97
|
"lib/gherkin/i18n.rb",
|
112
98
|
"lib/gherkin/i18n.yml",
|
113
99
|
"lib/gherkin/i18n_lexer.rb",
|
114
|
-
"lib/gherkin/
|
115
|
-
"lib/gherkin/parser.rb",
|
100
|
+
"lib/gherkin/parser/filter_listener.rb",
|
116
101
|
"lib/gherkin/parser/meta.txt",
|
102
|
+
"lib/gherkin/parser/parser.rb",
|
117
103
|
"lib/gherkin/parser/root.txt",
|
104
|
+
"lib/gherkin/parser/sexp.rb",
|
118
105
|
"lib/gherkin/parser/steps.txt",
|
106
|
+
"lib/gherkin/parser/tag_expression.rb",
|
119
107
|
"lib/gherkin/rb_lexer.rb",
|
120
108
|
"lib/gherkin/rb_lexer/.gitignore",
|
121
109
|
"lib/gherkin/rb_lexer/README.rdoc",
|
@@ -160,11 +148,8 @@ Gem::Specification.new do |s|
|
|
160
148
|
"lib/gherkin/rb_lexer/vi.rb",
|
161
149
|
"lib/gherkin/rb_lexer/zhCN.rb",
|
162
150
|
"lib/gherkin/rb_lexer/zhTW.rb",
|
163
|
-
"lib/gherkin/rb_parser.rb",
|
164
151
|
"lib/gherkin/tools.rb",
|
165
|
-
"lib/gherkin/tools/colors.rb",
|
166
152
|
"lib/gherkin/tools/files.rb",
|
167
|
-
"lib/gherkin/tools/pretty_listener.rb",
|
168
153
|
"lib/gherkin/tools/reformat.rb",
|
169
154
|
"lib/gherkin/tools/stats.rb",
|
170
155
|
"lib/gherkin/tools/stats_listener.rb",
|
@@ -187,19 +172,21 @@ Gem::Specification.new do |s|
|
|
187
172
|
"spec/gherkin/fixtures/simple.feature",
|
188
173
|
"spec/gherkin/fixtures/simple_with_comments.feature",
|
189
174
|
"spec/gherkin/fixtures/simple_with_tags.feature",
|
190
|
-
"spec/gherkin/
|
175
|
+
"spec/gherkin/formatter/argument_spec.rb",
|
176
|
+
"spec/gherkin/formatter/colors_spec.rb",
|
177
|
+
"spec/gherkin/formatter/pretty_listener_spec.rb",
|
191
178
|
"spec/gherkin/i18n_lexer_spec.rb",
|
192
179
|
"spec/gherkin/i18n_spec.rb",
|
193
180
|
"spec/gherkin/java_lexer_spec.rb",
|
194
|
-
"spec/gherkin/
|
181
|
+
"spec/gherkin/parser/filter_listener_spec.rb",
|
182
|
+
"spec/gherkin/parser/parser_spec.rb",
|
183
|
+
"spec/gherkin/parser/tag_expression_spec.rb",
|
195
184
|
"spec/gherkin/rb_lexer_spec.rb",
|
196
185
|
"spec/gherkin/sexp_recorder.rb",
|
197
186
|
"spec/gherkin/shared/lexer_spec.rb",
|
198
187
|
"spec/gherkin/shared/py_string_spec.rb",
|
199
188
|
"spec/gherkin/shared/row_spec.rb",
|
200
189
|
"spec/gherkin/shared/tags_spec.rb",
|
201
|
-
"spec/gherkin/tools/colors_spec.rb",
|
202
|
-
"spec/gherkin/tools/pretty_listener_spec.rb",
|
203
190
|
"spec/spec_helper.rb",
|
204
191
|
"tasks/bench.rake",
|
205
192
|
"tasks/bench/feature_builder.rb",
|
@@ -219,19 +206,21 @@ Gem::Specification.new do |s|
|
|
219
206
|
s.test_files = [
|
220
207
|
"spec/gherkin/c_lexer_spec.rb",
|
221
208
|
"spec/gherkin/csharp_lexer_spec.rb",
|
222
|
-
"spec/gherkin/
|
209
|
+
"spec/gherkin/formatter/argument_spec.rb",
|
210
|
+
"spec/gherkin/formatter/colors_spec.rb",
|
211
|
+
"spec/gherkin/formatter/pretty_listener_spec.rb",
|
223
212
|
"spec/gherkin/i18n_lexer_spec.rb",
|
224
213
|
"spec/gherkin/i18n_spec.rb",
|
225
214
|
"spec/gherkin/java_lexer_spec.rb",
|
226
|
-
"spec/gherkin/
|
215
|
+
"spec/gherkin/parser/filter_listener_spec.rb",
|
216
|
+
"spec/gherkin/parser/parser_spec.rb",
|
217
|
+
"spec/gherkin/parser/tag_expression_spec.rb",
|
227
218
|
"spec/gherkin/rb_lexer_spec.rb",
|
228
219
|
"spec/gherkin/sexp_recorder.rb",
|
229
220
|
"spec/gherkin/shared/lexer_spec.rb",
|
230
221
|
"spec/gherkin/shared/py_string_spec.rb",
|
231
222
|
"spec/gherkin/shared/row_spec.rb",
|
232
223
|
"spec/gherkin/shared/tags_spec.rb",
|
233
|
-
"spec/gherkin/tools/colors_spec.rb",
|
234
|
-
"spec/gherkin/tools/pretty_listener_spec.rb",
|
235
224
|
"spec/spec_helper.rb"
|
236
225
|
]
|
237
226
|
|
data/java/Gherkin.iml
CHANGED
@@ -1,22 +1,16 @@
|
|
1
1
|
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
-
<module type="JAVA_MODULE" version="4">
|
3
|
-
<component name="NewModuleRootManager" inherit-compiler-output="
|
4
|
-
<
|
2
|
+
<module org.jetbrains.idea.maven.project.MavenProjectsManager.isMavenModule="true" type="JAVA_MODULE" version="4">
|
3
|
+
<component name="NewModuleRootManager" inherit-compiler-output="false">
|
4
|
+
<output url="file://$MODULE_DIR$/target/classes" />
|
5
|
+
<output-test url="file://$MODULE_DIR$/target/test-classes" />
|
5
6
|
<content url="file://$MODULE_DIR$">
|
6
|
-
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
|
7
|
-
<sourceFolder url="file://$MODULE_DIR$/test" isTestSource="true" />
|
7
|
+
<sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" />
|
8
|
+
<sourceFolder url="file://$MODULE_DIR$/src/test/java" isTestSource="true" />
|
9
|
+
<excludeFolder url="file://$MODULE_DIR$/target" />
|
8
10
|
</content>
|
9
11
|
<orderEntry type="inheritedJdk" />
|
10
12
|
<orderEntry type="sourceFolder" forTests="false" />
|
11
|
-
<orderEntry type="
|
12
|
-
<library>
|
13
|
-
<CLASSES>
|
14
|
-
<root url="jar://$APPLICATION_HOME_DIR$/lib/junit-4.7.jar!/" />
|
15
|
-
</CLASSES>
|
16
|
-
<JAVADOC />
|
17
|
-
<SOURCES />
|
18
|
-
</library>
|
19
|
-
</orderEntry>
|
13
|
+
<orderEntry type="library" scope="TEST" name="Maven: junit:junit:4.8.1" level="project" />
|
20
14
|
</component>
|
21
15
|
</module>
|
22
16
|
|
File without changes
|
data/lib/gherkin.rb
CHANGED
@@ -1,2 +1,2 @@
|
|
1
1
|
require 'gherkin/i18n_lexer'
|
2
|
-
require 'gherkin/parser'
|
2
|
+
require 'gherkin/parser/parser'
|
data/lib/gherkin/c_lexer.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
module Gherkin
|
2
2
|
module CLexer
|
3
|
-
def self.[](
|
4
|
-
name =
|
3
|
+
def self.[](i18n_language_name)
|
4
|
+
name = i18n_language_name.gsub(/[\s-]/, '')
|
5
5
|
require "gherkin_lexer_#{name}"
|
6
6
|
i18n_lexer_class_name = name.capitalize
|
7
7
|
const_get(i18n_lexer_class_name)
|
@@ -1,7 +1,7 @@
|
|
1
1
|
require 'term/ansicolor'
|
2
2
|
|
3
3
|
module Gherkin
|
4
|
-
module
|
4
|
+
module Formatter
|
5
5
|
# Defines aliases for coloured output. You don't invoke any methods from this
|
6
6
|
# module directly, but you can change the output colours by defining
|
7
7
|
# a <tt>GHERKIN_COLORS</tt> variable in your shell, very much like how you can
|
@@ -1,14 +1,13 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
|
3
|
-
require 'gherkin/
|
4
|
-
require 'gherkin/
|
3
|
+
require 'gherkin/formatter/colors'
|
4
|
+
require 'gherkin/formatter/monochrome_format'
|
5
|
+
require 'gherkin/formatter/argument'
|
5
6
|
|
6
7
|
module Gherkin
|
7
|
-
module
|
8
|
-
# TODO: Rename to Gherkin::Pretty::PrettyReporter - that's what this class *does*
|
9
|
-
# (The fact that it conforms to the Gherkin Listener interface is secondary)
|
8
|
+
module Formatter
|
10
9
|
class PrettyListener
|
11
|
-
include
|
10
|
+
include Colors
|
12
11
|
|
13
12
|
class << self
|
14
13
|
def new(io, monochrome=false)
|
@@ -24,14 +23,14 @@ module Gherkin
|
|
24
23
|
def initialize(io, monochrome=false)
|
25
24
|
@io = io
|
26
25
|
@monochrome = monochrome
|
27
|
-
@format = @monochrome ?
|
26
|
+
@format = @monochrome ? MonochromeFormat.new : AnsiColorFormat.new
|
28
27
|
@tags = nil
|
29
28
|
@comments = nil
|
30
29
|
end
|
31
30
|
|
32
31
|
def tag(name, line)
|
33
32
|
@tags ||= []
|
34
|
-
@tags <<
|
33
|
+
@tags << name
|
35
34
|
end
|
36
35
|
|
37
36
|
def comment(content, line)
|
@@ -65,7 +64,7 @@ module Gherkin
|
|
65
64
|
def step(keyword, name, line, status=nil, arguments=nil, location=nil)
|
66
65
|
flush_table
|
67
66
|
status_param = "#{status}_param" if status
|
68
|
-
name = Gherkin::
|
67
|
+
name = Gherkin::Formatter::Argument.format(name, @format, (arguments || []))
|
69
68
|
#{|arg| status_param ? self.__send__(status_param, arg, @monochrome) : arg} if arguments
|
70
69
|
|
71
70
|
step = "#{keyword}#{indent(name, ' ')}"
|
data/lib/gherkin/i18n.rb
CHANGED
@@ -46,6 +46,33 @@ module Gherkin
|
|
46
46
|
@keywords['grammar_name'] = @keywords['name'].gsub(/\s/, '')
|
47
47
|
end
|
48
48
|
|
49
|
+
def lexer(listener, force_ruby)
|
50
|
+
begin
|
51
|
+
if force_ruby
|
52
|
+
rb(listener)
|
53
|
+
else
|
54
|
+
begin
|
55
|
+
c(listener)
|
56
|
+
rescue NameError, LoadError => e
|
57
|
+
warn("WARNING: #{e.message}. Reverting to Ruby lexer.")
|
58
|
+
rb(listener)
|
59
|
+
end
|
60
|
+
end
|
61
|
+
rescue LoadError => e
|
62
|
+
raise I18nLexerNotFound, "No lexer was found for #{i18n_language_name} (#{e.message}). Supported languages are listed in gherkin/i18n.yml."
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
def c(listener)
|
67
|
+
require 'gherkin/c_lexer'
|
68
|
+
CLexer[@key].new(listener)
|
69
|
+
end
|
70
|
+
|
71
|
+
def rb(listener)
|
72
|
+
require 'gherkin/rb_lexer'
|
73
|
+
RbLexer[@key].new(listener)
|
74
|
+
end
|
75
|
+
|
49
76
|
def sanitized_key
|
50
77
|
@key.gsub(/[\s-]/, '')
|
51
78
|
end
|
@@ -95,11 +122,6 @@ module Gherkin
|
|
95
122
|
@keywords[key].split('|').map{|kw| space ? keyword_space(kw) : kw}
|
96
123
|
end
|
97
124
|
|
98
|
-
def adverbs
|
99
|
-
# TODO: looks very similar to #step_keywords. Lose this? Where is it used from?
|
100
|
-
%w{given when then and but}.map{|keyword| @keywords[keyword].split('|').map{|w| w.gsub(/[\s<']/, '')}}.flatten
|
101
|
-
end
|
102
|
-
|
103
125
|
private
|
104
126
|
|
105
127
|
def keyword_space(val)
|
data/lib/gherkin/i18n_lexer.rb
CHANGED
@@ -11,63 +11,37 @@ module Gherkin
|
|
11
11
|
attr_reader :i18n_language
|
12
12
|
|
13
13
|
class << self
|
14
|
-
def new(
|
14
|
+
def new(listener, force_ruby)
|
15
15
|
if !force_ruby && defined?(JRUBY_VERSION)
|
16
16
|
require 'gherkin.jar'
|
17
|
-
Java::Gherkin::I18nLexer.new(
|
17
|
+
Java::Gherkin::I18nLexer.new(listener)
|
18
18
|
else
|
19
19
|
super
|
20
20
|
end
|
21
21
|
end
|
22
|
+
end
|
22
23
|
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
else
|
28
|
-
begin
|
29
|
-
c[i18n_lang]
|
30
|
-
rescue NameError, LoadError => e
|
31
|
-
warn("WARNING: #{e.message}. Reverting to Ruby lexer.")
|
32
|
-
rb[i18n_lang]
|
33
|
-
end
|
34
|
-
end
|
35
|
-
rescue LoadError => e
|
36
|
-
raise I18nLexerNotFound, "No lexer was found for #{i18n_lang} (#{e.message}). Supported languages are listed in gherkin/i18n.yml."
|
37
|
-
end
|
38
|
-
end
|
39
|
-
|
40
|
-
def i18n_language(source)
|
41
|
-
line_one = source.split(/\n/)[0]
|
42
|
-
match = LANGUAGE_PATTERN.match(line_one)
|
43
|
-
I18n.get(match ? match[1] : 'en').key
|
44
|
-
end
|
24
|
+
def initialize(listener, force_ruby)
|
25
|
+
@listener = listener
|
26
|
+
@force_ruby = force_ruby
|
27
|
+
end
|
45
28
|
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
end
|
29
|
+
def scan(source)
|
30
|
+
create_delegate(source).scan(source)
|
31
|
+
end
|
50
32
|
|
51
|
-
|
52
|
-
require 'gherkin/csharp_lexer'
|
53
|
-
CSharpLexer
|
54
|
-
end
|
33
|
+
private
|
55
34
|
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
end
|
35
|
+
def create_delegate(source)
|
36
|
+
@i18n_language = lang(source)
|
37
|
+
@i18n_language.lexer(@listener, @force_ruby)
|
60
38
|
end
|
61
39
|
|
62
|
-
def
|
63
|
-
|
64
|
-
|
40
|
+
def lang(source)
|
41
|
+
line_one = source.split(/\n/)[0]
|
42
|
+
match = LANGUAGE_PATTERN.match(line_one)
|
43
|
+
I18n.get(match ? match[1] : 'en')
|
65
44
|
end
|
66
45
|
|
67
|
-
def scan(source)
|
68
|
-
@i18n_language = self.class.i18n_language(source)
|
69
|
-
delegate = self.class.lexer_class(@i18n_language, @force_ruby).new(@parser)
|
70
|
-
delegate.scan(source)
|
71
|
-
end
|
72
46
|
end
|
73
47
|
end
|