gherkin 1.0.3-java → 1.0.4-java
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,12 +5,12 @@
|
|
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
|
s.platform = %q{java}
|
10
10
|
|
11
11
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
12
12
|
s.authors = ["Mike Sassak", "Gregory Hnatiuk", "Aslak Helles\303\270y"]
|
13
|
-
s.date = %q{2010-
|
13
|
+
s.date = %q{2010-04-07}
|
14
14
|
s.default_executable = %q{gherkin}
|
15
15
|
s.description = %q{A fast Gherkin lexer/parser based on the Ragel State Machine Compiler.}
|
16
16
|
s.email = %q{cukes@googlegroups.com}
|
@@ -36,29 +36,13 @@ Gem::Specification.new do |s|
|
|
36
36
|
"features/parser_with_native_lexer.feature",
|
37
37
|
"features/pretty_printer.feature",
|
38
38
|
"features/step_definitions/gherkin_steps.rb",
|
39
|
-
"features/step_definitions/
|
39
|
+
"features/step_definitions/pretty_listener_step.rb",
|
40
40
|
"features/steps_parser.feature",
|
41
41
|
"features/support/env.rb",
|
42
42
|
"gherkin.gemspec",
|
43
43
|
"java/.gitignore",
|
44
44
|
"java/Gherkin.iml",
|
45
|
-
"java/
|
46
|
-
"java/src/gherkin/FixJava.java",
|
47
|
-
"java/src/gherkin/I18nLexer.java",
|
48
|
-
"java/src/gherkin/Lexer.java",
|
49
|
-
"java/src/gherkin/LexingError.java",
|
50
|
-
"java/src/gherkin/Listener.java",
|
51
|
-
"java/src/gherkin/Main.java",
|
52
|
-
"java/src/gherkin/ParseError.java",
|
53
|
-
"java/src/gherkin/Parser.java",
|
54
|
-
"java/src/gherkin/formatter/Argument.java",
|
55
|
-
"java/src/gherkin/formatter/ArgumentFormat.java",
|
56
|
-
"java/src/gherkin/formatter/Colors.java",
|
57
|
-
"java/src/gherkin/formatter/Formatter.java",
|
58
|
-
"java/src/gherkin/formatter/PrettyFormatter.java",
|
59
|
-
"java/src/gherkin/lexer/.gitignore",
|
60
|
-
"java/src/gherkin/parser/StateMachineReader.java",
|
61
|
-
"java/test/gherkin/formatter/ArgumentTest.java",
|
45
|
+
"java/src/main/java/gherkin/lexer/.gitignore",
|
62
46
|
"lib/.gitignore",
|
63
47
|
"lib/gherkin.jar",
|
64
48
|
"lib/gherkin.rb",
|
@@ -66,24 +50,25 @@ Gem::Specification.new do |s|
|
|
66
50
|
"lib/gherkin/cli/main.rb",
|
67
51
|
"lib/gherkin/core_ext/array.rb",
|
68
52
|
"lib/gherkin/csharp_lexer.rb",
|
69
|
-
"lib/gherkin/
|
70
|
-
"lib/gherkin/
|
53
|
+
"lib/gherkin/formatter/argument.rb",
|
54
|
+
"lib/gherkin/formatter/colors.rb",
|
55
|
+
"lib/gherkin/formatter/monochrome_format.rb",
|
56
|
+
"lib/gherkin/formatter/pretty_listener.rb",
|
71
57
|
"lib/gherkin/i18n.rb",
|
72
58
|
"lib/gherkin/i18n.yml",
|
73
59
|
"lib/gherkin/i18n_lexer.rb",
|
74
|
-
"lib/gherkin/
|
75
|
-
"lib/gherkin/parser.rb",
|
60
|
+
"lib/gherkin/parser/filter_listener.rb",
|
76
61
|
"lib/gherkin/parser/meta.txt",
|
62
|
+
"lib/gherkin/parser/parser.rb",
|
77
63
|
"lib/gherkin/parser/root.txt",
|
64
|
+
"lib/gherkin/parser/sexp.rb",
|
78
65
|
"lib/gherkin/parser/steps.txt",
|
66
|
+
"lib/gherkin/parser/tag_expression.rb",
|
79
67
|
"lib/gherkin/rb_lexer.rb",
|
80
68
|
"lib/gherkin/rb_lexer/.gitignore",
|
81
69
|
"lib/gherkin/rb_lexer/README.rdoc",
|
82
|
-
"lib/gherkin/rb_parser.rb",
|
83
70
|
"lib/gherkin/tools.rb",
|
84
|
-
"lib/gherkin/tools/colors.rb",
|
85
71
|
"lib/gherkin/tools/files.rb",
|
86
|
-
"lib/gherkin/tools/pretty_listener.rb",
|
87
72
|
"lib/gherkin/tools/reformat.rb",
|
88
73
|
"lib/gherkin/tools/stats.rb",
|
89
74
|
"lib/gherkin/tools/stats_listener.rb",
|
@@ -106,19 +91,21 @@ Gem::Specification.new do |s|
|
|
106
91
|
"spec/gherkin/fixtures/simple.feature",
|
107
92
|
"spec/gherkin/fixtures/simple_with_comments.feature",
|
108
93
|
"spec/gherkin/fixtures/simple_with_tags.feature",
|
109
|
-
"spec/gherkin/
|
94
|
+
"spec/gherkin/formatter/argument_spec.rb",
|
95
|
+
"spec/gherkin/formatter/colors_spec.rb",
|
96
|
+
"spec/gherkin/formatter/pretty_listener_spec.rb",
|
110
97
|
"spec/gherkin/i18n_lexer_spec.rb",
|
111
98
|
"spec/gherkin/i18n_spec.rb",
|
112
99
|
"spec/gherkin/java_lexer_spec.rb",
|
113
|
-
"spec/gherkin/
|
100
|
+
"spec/gherkin/parser/filter_listener_spec.rb",
|
101
|
+
"spec/gherkin/parser/parser_spec.rb",
|
102
|
+
"spec/gherkin/parser/tag_expression_spec.rb",
|
114
103
|
"spec/gherkin/rb_lexer_spec.rb",
|
115
104
|
"spec/gherkin/sexp_recorder.rb",
|
116
105
|
"spec/gherkin/shared/lexer_spec.rb",
|
117
106
|
"spec/gherkin/shared/py_string_spec.rb",
|
118
107
|
"spec/gherkin/shared/row_spec.rb",
|
119
108
|
"spec/gherkin/shared/tags_spec.rb",
|
120
|
-
"spec/gherkin/tools/colors_spec.rb",
|
121
|
-
"spec/gherkin/tools/pretty_listener_spec.rb",
|
122
109
|
"spec/spec_helper.rb",
|
123
110
|
"tasks/bench.rake",
|
124
111
|
"tasks/bench/feature_builder.rb",
|
@@ -138,19 +125,21 @@ Gem::Specification.new do |s|
|
|
138
125
|
s.test_files = [
|
139
126
|
"spec/gherkin/c_lexer_spec.rb",
|
140
127
|
"spec/gherkin/csharp_lexer_spec.rb",
|
141
|
-
"spec/gherkin/
|
128
|
+
"spec/gherkin/formatter/argument_spec.rb",
|
129
|
+
"spec/gherkin/formatter/colors_spec.rb",
|
130
|
+
"spec/gherkin/formatter/pretty_listener_spec.rb",
|
142
131
|
"spec/gherkin/i18n_lexer_spec.rb",
|
143
132
|
"spec/gherkin/i18n_spec.rb",
|
144
133
|
"spec/gherkin/java_lexer_spec.rb",
|
145
|
-
"spec/gherkin/
|
134
|
+
"spec/gherkin/parser/filter_listener_spec.rb",
|
135
|
+
"spec/gherkin/parser/parser_spec.rb",
|
136
|
+
"spec/gherkin/parser/tag_expression_spec.rb",
|
146
137
|
"spec/gherkin/rb_lexer_spec.rb",
|
147
138
|
"spec/gherkin/sexp_recorder.rb",
|
148
139
|
"spec/gherkin/shared/lexer_spec.rb",
|
149
140
|
"spec/gherkin/shared/py_string_spec.rb",
|
150
141
|
"spec/gherkin/shared/row_spec.rb",
|
151
142
|
"spec/gherkin/shared/tags_spec.rb",
|
152
|
-
"spec/gherkin/tools/colors_spec.rb",
|
153
|
-
"spec/gherkin/tools/pretty_listener_spec.rb",
|
154
143
|
"spec/spec_helper.rb"
|
155
144
|
]
|
156
145
|
|
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
|