gherkin 1.0.2-i386-mswin32 → 1.0.3-i386-mswin32
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitattributes +1 -0
- data/History.txt +18 -0
- data/README.rdoc +12 -1
- data/Rakefile +4 -2
- data/VERSION.yml +1 -1
- data/bin/gherkin +1 -1
- data/dotnet/.gitignore +13 -0
- data/features/feature_parser.feature +22 -2
- data/features/native_lexer.feature +1 -1
- data/features/parser_with_native_lexer.feature +1 -1
- data/features/step_definitions/gherkin_steps.rb +2 -6
- data/features/step_definitions/pretty_printer_steps.rb +2 -3
- data/features/steps_parser.feature +1 -1
- data/gherkin.gemspec +40 -13
- data/java/Gherkin.iml +2 -4
- data/java/build.xml +3 -0
- data/java/src/gherkin/FixJava.java +6 -3
- data/java/src/gherkin/I18nLexer.java +48 -0
- data/java/src/gherkin/Listener.java +3 -1
- data/java/src/gherkin/Main.java +17 -0
- data/java/src/gherkin/Parser.java +9 -3
- data/java/src/gherkin/formatter/Argument.java +39 -0
- data/java/src/gherkin/formatter/ArgumentFormat.java +17 -0
- data/java/src/gherkin/formatter/Colors.java +7 -0
- data/java/src/gherkin/formatter/Formatter.java +15 -0
- data/java/src/gherkin/formatter/PrettyFormatter.java +219 -0
- data/java/src/gherkin/parser/StateMachineReader.java +8 -3
- data/java/test/gherkin/formatter/ArgumentTest.java +17 -0
- data/lib/gherkin/csharp_lexer.rb +15 -0
- data/lib/gherkin/format/argument.rb +35 -0
- data/lib/gherkin/format/monochrome_format.rb +9 -0
- data/lib/gherkin/i18n.rb +22 -0
- data/lib/gherkin/i18n.yml +34 -20
- data/lib/gherkin/i18n_lexer.rb +57 -13
- data/lib/gherkin/lexer.rb +9 -18
- data/lib/gherkin/parser.rb +3 -3
- data/lib/gherkin/parser/meta.txt +5 -4
- data/lib/gherkin/parser/root.txt +11 -9
- data/lib/gherkin/parser/steps.txt +4 -3
- data/lib/gherkin/rb_parser.rb +13 -5
- data/lib/gherkin/tools/colors.rb +119 -0
- data/lib/gherkin/tools/files.rb +6 -1
- data/lib/gherkin/tools/pretty_listener.rb +115 -23
- data/ragel/lexer.c.rl.erb +67 -51
- data/ragel/lexer.csharp.rl.erb +240 -0
- data/ragel/lexer.java.rl.erb +27 -18
- data/ragel/lexer.rb.rl.erb +17 -17
- data/ragel/lexer_common.rl.erb +8 -8
- data/spec/gherkin/c_lexer_spec.rb +4 -4
- data/spec/gherkin/csharp_lexer_spec.rb +20 -0
- data/spec/gherkin/fixtures/comments_in_table.feature +9 -0
- data/spec/gherkin/fixtures/complex.feature +2 -0
- data/spec/gherkin/fixtures/dos_line_endings.feature +45 -0
- data/spec/gherkin/fixtures/i18n_fr.feature +1 -0
- data/spec/gherkin/fixtures/i18n_no.feature +1 -0
- data/spec/gherkin/fixtures/i18n_zh-CN.feature +1 -0
- data/spec/gherkin/format/argument_spec.rb +28 -0
- data/spec/gherkin/i18n_lexer_spec.rb +4 -4
- data/spec/gherkin/i18n_spec.rb +31 -23
- data/spec/gherkin/java_lexer_spec.rb +4 -3
- data/spec/gherkin/parser_spec.rb +5 -0
- data/spec/gherkin/rb_lexer_spec.rb +4 -2
- data/spec/gherkin/sexp_recorder.rb +1 -1
- data/spec/gherkin/shared/lexer_spec.rb +169 -60
- data/spec/gherkin/shared/py_string_spec.rb +6 -0
- data/spec/gherkin/shared/row_spec.rb +107 -0
- data/spec/gherkin/shared/tags_spec.rb +1 -1
- data/spec/gherkin/tools/colors_spec.rb +19 -0
- data/spec/gherkin/tools/pretty_listener_spec.rb +147 -0
- data/spec/spec_helper.rb +31 -7
- data/tasks/compile.rake +81 -7
- data/tasks/ragel_task.rb +6 -4
- data/tasks/rspec.rake +2 -2
- metadata +86 -26
- data/lib/gherkin/java_lexer.rb +0 -10
- data/spec/gherkin/shared/table_spec.rb +0 -97
data/.gitattributes
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
spec/gherkin/fixtures/dos_line_endings.feature -crlf
|
data/History.txt
CHANGED
@@ -1,3 +1,21 @@
|
|
1
|
+
== In Git
|
2
|
+
|
3
|
+
== Bugfixes
|
4
|
+
* The C lexer correctly instantiates a new array for each table, instead of reusing the old one. (Aslak Hellesøy)
|
5
|
+
* Emit keywords with space instead of stripping (< keywords are emmitted without space) (Aslak Hellesøy)
|
6
|
+
* gherkin reformat now prints comments, and does it with proper indentation (Aslak Hellesøy)
|
7
|
+
* .NET resource files are now automatically copied into the .dll (#46 Aslak Hellesøy)
|
8
|
+
|
9
|
+
== New features
|
10
|
+
* The Pure Java implementation now has a simple main method that pretty prints a feature. (#39 Aslak Hellesøy)
|
11
|
+
* Writing code generated i18n syntax highlighters for Gherkin is a lot easier thanks to several convenience methods in Gherkin::I18n. (Aslak Hellesøy)
|
12
|
+
* .NET (C#) port (#36, #37 Attila Sztupak)
|
13
|
+
* Tables parsed and sent by row rather than by table. (Mike Sassak)
|
14
|
+
|
15
|
+
== Changed features
|
16
|
+
* Switced to ISO 639-1 (language) and ISO 3166 alpha-2 (region - if applicable). Applies to Catalan,
|
17
|
+
Swedish, Welsh, Romanian and Serbian. (Aslak Hellesøy)
|
18
|
+
|
1
19
|
== 1.0.2 (2009-12-30)
|
2
20
|
|
3
21
|
== Bugfixes
|
data/README.rdoc
CHANGED
@@ -9,6 +9,9 @@ Fast Gherkin lexer and parser based on Ragel. Gherkin is two things:
|
|
9
9
|
|
10
10
|
rake clean spec cucumber
|
11
11
|
|
12
|
+
If the RL_LANG environment variable is set, only the parsers for the languages specified there will be built.
|
13
|
+
E.g. in Bash, export RL_LANG="en,fr,no". This can be quite helpful when modifying the Ragel grammar.
|
14
|
+
|
12
15
|
== Release process
|
13
16
|
|
14
17
|
* Run "rake clean spec cucumber" for each platform (1.8.6, 1.8.7, 1.9, jruby) to make sure all is green.
|
@@ -17,10 +20,18 @@ rake clean spec cucumber
|
|
17
20
|
* rake clean jar compile
|
18
21
|
* rake gemspec
|
19
22
|
* git commit -a -m "Release vX.Y.Z"
|
20
|
-
* rake release
|
23
|
+
* rake gemcutter:release
|
21
24
|
* ./nativegems.sh
|
22
25
|
* gem push pkg/... (for each native gem)
|
23
26
|
|
27
|
+
== Configuring Rake-Compiler for cross compilation
|
28
|
+
In order to build Windows binaries (so we can release Windows gems from OS X/Linux) we need to set up rake-compiler.
|
29
|
+
|
30
|
+
http://github.com/luislavena/rake-compiler/
|
31
|
+
|
32
|
+
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:
|
33
|
+
http://crossgcc.rts-software.org/doku.php - just add the bin folder to your PATH
|
34
|
+
|
24
35
|
== Note on Patches/Pull Requests
|
25
36
|
|
26
37
|
* Fork the project.
|
data/Rakefile
CHANGED
@@ -15,10 +15,12 @@ begin
|
|
15
15
|
gem.authors = ["Mike Sassak", "Gregory Hnatiuk", "Aslak Hellesøy"]
|
16
16
|
gem.executables = ["gherkin"]
|
17
17
|
gem.add_dependency "trollop", ">= 1.15"
|
18
|
-
gem.add_development_dependency "rspec", ">= 1.
|
19
|
-
gem.add_development_dependency "cucumber", ">= 0.
|
18
|
+
gem.add_development_dependency "rspec", ">= 1.3.0"
|
19
|
+
gem.add_development_dependency "cucumber", ">= 0.6.2"
|
20
20
|
gem.add_development_dependency "rake-compiler", ">= 0.7.0" unless defined?(JRUBY_VERSION)
|
21
|
+
gem.add_development_dependency "albacore", ">= 0.1.0"
|
21
22
|
|
23
|
+
gem.files -= FileList['dotnet/**/*']
|
22
24
|
case ENV['PLATFORM']
|
23
25
|
when 'java'
|
24
26
|
gem.platform = 'java'
|
data/VERSION.yml
CHANGED
data/bin/gherkin
CHANGED
data/dotnet/.gitignore
ADDED
@@ -6,7 +6,7 @@ Feature: Gherkin Feature lexer
|
|
6
6
|
make all the syntax decisions for me
|
7
7
|
|
8
8
|
Background:
|
9
|
-
Given a "
|
9
|
+
Given a "ruby" "root" parser
|
10
10
|
|
11
11
|
Scenario: Correctly formed feature
|
12
12
|
Given the following text is parsed:
|
@@ -92,7 +92,7 @@ Feature: Gherkin Feature lexer
|
|
92
92
|
"""
|
93
93
|
Then there should be parse errors on lines 5, 10 and 12
|
94
94
|
|
95
|
-
Scenario: Tables
|
95
|
+
Scenario: Malformed Tables
|
96
96
|
Given the following text is parsed:
|
97
97
|
"""
|
98
98
|
Feature: Antiques Roadshow
|
@@ -115,6 +115,26 @@ Feature: Gherkin Feature lexer
|
|
115
115
|
"""
|
116
116
|
Then there should be parse errors on lines 10 and 17
|
117
117
|
|
118
|
+
Scenario: Well-formed Tables
|
119
|
+
Given the following text is parsed:
|
120
|
+
"""
|
121
|
+
Feature: Row-by-row
|
122
|
+
|
123
|
+
Scenario: Tables with comments!
|
124
|
+
Given I can now comment out a row:
|
125
|
+
| Key | Value |
|
126
|
+
# | Yes | No |
|
127
|
+
# | Good | Bad |
|
128
|
+
| Good | Evil |
|
129
|
+
Then I am pleased by these things:
|
130
|
+
| Raindrops | Roses |
|
131
|
+
# | Whiskers | Kittens |
|
132
|
+
| Bright Copper | Kettles |
|
133
|
+
# | Warm woolen | Mittens |
|
134
|
+
| Also Oban | And Hendricks |
|
135
|
+
"""
|
136
|
+
Then there should be no parse errors
|
137
|
+
|
118
138
|
Scenario: Multiline keyword descriptions
|
119
139
|
Given the following text is parsed:
|
120
140
|
"""
|
@@ -1,10 +1,6 @@
|
|
1
|
-
Given /^a "([^\"]*)"
|
1
|
+
Given /^a "([^\"]*)" "([^\"]*)" parser$/ do |ruby_or_native, parser_name|
|
2
2
|
parser = Gherkin::Parser.new(@listener, false, parser_name)
|
3
|
-
|
4
|
-
'ruby' => 'rb',
|
5
|
-
'native' => (defined?(JRUBY_VERSION) ? 'java' : 'c')
|
6
|
-
}[impl]
|
7
|
-
@lexer = Gherkin::Lexer.send(programming_language)[i18n_language].new(parser)
|
3
|
+
@lexer = Gherkin::I18nLexer.new(parser, ruby_or_native == "ruby")
|
8
4
|
end
|
9
5
|
|
10
6
|
Given "the following text is parsed:" do |text|
|
@@ -31,13 +31,12 @@ When /^I parse the prettified representation of each of them$/ do
|
|
31
31
|
pretty1 = nil
|
32
32
|
pretty2 = nil
|
33
33
|
begin
|
34
|
-
# announce "========== #{feature}:"
|
35
34
|
pretty1 = pretty(IO.read(feature))
|
36
35
|
pretty2 = pretty(pretty1)
|
37
36
|
pretty2.should == pretty1
|
38
37
|
rescue Spec::Expectations::ExpectationNotMetError => e
|
39
|
-
File.open("p1.feature", "
|
40
|
-
File.open("p2.feature", "
|
38
|
+
File.open("p1.feature", "wb") {|io| io.write(pretty1)}
|
39
|
+
File.open("p2.feature", "wb") {|io| io.write(pretty2)}
|
41
40
|
announce "========== #{feature}:"
|
42
41
|
if(e.message =~ /(@@.*)/m)
|
43
42
|
announce $1
|
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.3"
|
9
9
|
s.platform = %q{i386-mswin32}
|
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{
|
13
|
+
s.date = %q{2010-03-30}
|
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}
|
@@ -20,7 +20,8 @@ Gem::Specification.new do |s|
|
|
20
20
|
"README.rdoc"
|
21
21
|
]
|
22
22
|
s.files = [
|
23
|
-
".
|
23
|
+
".gitattributes",
|
24
|
+
".gitignore",
|
24
25
|
".mailmap",
|
25
26
|
"History.txt",
|
26
27
|
"LICENSE",
|
@@ -29,6 +30,7 @@ Gem::Specification.new do |s|
|
|
29
30
|
"VERSION.yml",
|
30
31
|
"bin/gherkin",
|
31
32
|
"cucumber.yml",
|
33
|
+
"dotnet/.gitignore",
|
32
34
|
"features/feature_parser.feature",
|
33
35
|
"features/native_lexer.feature",
|
34
36
|
"features/parser_with_native_lexer.feature",
|
@@ -42,22 +44,32 @@ Gem::Specification.new do |s|
|
|
42
44
|
"java/Gherkin.iml",
|
43
45
|
"java/build.xml",
|
44
46
|
"java/src/gherkin/FixJava.java",
|
47
|
+
"java/src/gherkin/I18nLexer.java",
|
45
48
|
"java/src/gherkin/Lexer.java",
|
46
49
|
"java/src/gherkin/LexingError.java",
|
47
50
|
"java/src/gherkin/Listener.java",
|
51
|
+
"java/src/gherkin/Main.java",
|
48
52
|
"java/src/gherkin/ParseError.java",
|
49
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",
|
50
59
|
"java/src/gherkin/lexer/.gitignore",
|
51
60
|
"java/src/gherkin/parser/StateMachineReader.java",
|
61
|
+
"java/test/gherkin/formatter/ArgumentTest.java",
|
52
62
|
"lib/.gitignore",
|
53
63
|
"lib/gherkin.rb",
|
54
64
|
"lib/gherkin/c_lexer.rb",
|
55
65
|
"lib/gherkin/cli/main.rb",
|
56
66
|
"lib/gherkin/core_ext/array.rb",
|
67
|
+
"lib/gherkin/csharp_lexer.rb",
|
68
|
+
"lib/gherkin/format/argument.rb",
|
69
|
+
"lib/gherkin/format/monochrome_format.rb",
|
57
70
|
"lib/gherkin/i18n.rb",
|
58
71
|
"lib/gherkin/i18n.yml",
|
59
72
|
"lib/gherkin/i18n_lexer.rb",
|
60
|
-
"lib/gherkin/java_lexer.rb",
|
61
73
|
"lib/gherkin/lexer.rb",
|
62
74
|
"lib/gherkin/parser.rb",
|
63
75
|
"lib/gherkin/parser/meta.txt",
|
@@ -68,6 +80,7 @@ Gem::Specification.new do |s|
|
|
68
80
|
"lib/gherkin/rb_lexer/README.rdoc",
|
69
81
|
"lib/gherkin/rb_parser.rb",
|
70
82
|
"lib/gherkin/tools.rb",
|
83
|
+
"lib/gherkin/tools/colors.rb",
|
71
84
|
"lib/gherkin/tools/files.rb",
|
72
85
|
"lib/gherkin/tools/pretty_listener.rb",
|
73
86
|
"lib/gherkin/tools/reformat.rb",
|
@@ -76,18 +89,23 @@ Gem::Specification.new do |s|
|
|
76
89
|
"nativegems.sh",
|
77
90
|
"ragel/i18n/.gitignore",
|
78
91
|
"ragel/lexer.c.rl.erb",
|
92
|
+
"ragel/lexer.csharp.rl.erb",
|
79
93
|
"ragel/lexer.java.rl.erb",
|
80
94
|
"ragel/lexer.rb.rl.erb",
|
81
95
|
"ragel/lexer_common.rl.erb",
|
82
96
|
"spec/gherkin/c_lexer_spec.rb",
|
97
|
+
"spec/gherkin/csharp_lexer_spec.rb",
|
83
98
|
"spec/gherkin/fixtures/1.feature",
|
99
|
+
"spec/gherkin/fixtures/comments_in_table.feature",
|
84
100
|
"spec/gherkin/fixtures/complex.feature",
|
101
|
+
"spec/gherkin/fixtures/dos_line_endings.feature",
|
85
102
|
"spec/gherkin/fixtures/i18n_fr.feature",
|
86
103
|
"spec/gherkin/fixtures/i18n_no.feature",
|
87
104
|
"spec/gherkin/fixtures/i18n_zh-CN.feature",
|
88
105
|
"spec/gherkin/fixtures/simple.feature",
|
89
106
|
"spec/gherkin/fixtures/simple_with_comments.feature",
|
90
107
|
"spec/gherkin/fixtures/simple_with_tags.feature",
|
108
|
+
"spec/gherkin/format/argument_spec.rb",
|
91
109
|
"spec/gherkin/i18n_lexer_spec.rb",
|
92
110
|
"spec/gherkin/i18n_spec.rb",
|
93
111
|
"spec/gherkin/java_lexer_spec.rb",
|
@@ -96,8 +114,10 @@ Gem::Specification.new do |s|
|
|
96
114
|
"spec/gherkin/sexp_recorder.rb",
|
97
115
|
"spec/gherkin/shared/lexer_spec.rb",
|
98
116
|
"spec/gherkin/shared/py_string_spec.rb",
|
99
|
-
"spec/gherkin/shared/
|
117
|
+
"spec/gherkin/shared/row_spec.rb",
|
100
118
|
"spec/gherkin/shared/tags_spec.rb",
|
119
|
+
"spec/gherkin/tools/colors_spec.rb",
|
120
|
+
"spec/gherkin/tools/pretty_listener_spec.rb",
|
101
121
|
"spec/spec_helper.rb",
|
102
122
|
"tasks/bench.rake",
|
103
123
|
"tasks/bench/feature_builder.rb",
|
@@ -112,10 +132,12 @@ Gem::Specification.new do |s|
|
|
112
132
|
s.homepage = %q{http://github.com/aslakhellesoy/gherkin}
|
113
133
|
s.rdoc_options = ["--charset=UTF-8"]
|
114
134
|
s.require_paths = ["lib"]
|
115
|
-
s.rubygems_version = %q{1.3.
|
135
|
+
s.rubygems_version = %q{1.3.6}
|
116
136
|
s.summary = %q{Fast Gherkin lexer/parser}
|
117
137
|
s.test_files = [
|
118
138
|
"spec/gherkin/c_lexer_spec.rb",
|
139
|
+
"spec/gherkin/csharp_lexer_spec.rb",
|
140
|
+
"spec/gherkin/format/argument_spec.rb",
|
119
141
|
"spec/gherkin/i18n_lexer_spec.rb",
|
120
142
|
"spec/gherkin/i18n_spec.rb",
|
121
143
|
"spec/gherkin/java_lexer_spec.rb",
|
@@ -124,8 +146,10 @@ Gem::Specification.new do |s|
|
|
124
146
|
"spec/gherkin/sexp_recorder.rb",
|
125
147
|
"spec/gherkin/shared/lexer_spec.rb",
|
126
148
|
"spec/gherkin/shared/py_string_spec.rb",
|
127
|
-
"spec/gherkin/shared/
|
149
|
+
"spec/gherkin/shared/row_spec.rb",
|
128
150
|
"spec/gherkin/shared/tags_spec.rb",
|
151
|
+
"spec/gherkin/tools/colors_spec.rb",
|
152
|
+
"spec/gherkin/tools/pretty_listener_spec.rb",
|
129
153
|
"spec/spec_helper.rb"
|
130
154
|
]
|
131
155
|
|
@@ -135,20 +159,23 @@ Gem::Specification.new do |s|
|
|
135
159
|
|
136
160
|
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
137
161
|
s.add_runtime_dependency(%q<trollop>, [">= 1.15"])
|
138
|
-
s.add_development_dependency(%q<rspec>, [">= 1.
|
139
|
-
s.add_development_dependency(%q<cucumber>, [">= 0.
|
162
|
+
s.add_development_dependency(%q<rspec>, [">= 1.3.0"])
|
163
|
+
s.add_development_dependency(%q<cucumber>, [">= 0.6.2"])
|
140
164
|
s.add_development_dependency(%q<rake-compiler>, [">= 0.7.0"])
|
165
|
+
s.add_development_dependency(%q<albacore>, [">= 0.1.0"])
|
141
166
|
else
|
142
167
|
s.add_dependency(%q<trollop>, [">= 1.15"])
|
143
|
-
s.add_dependency(%q<rspec>, [">= 1.
|
144
|
-
s.add_dependency(%q<cucumber>, [">= 0.
|
168
|
+
s.add_dependency(%q<rspec>, [">= 1.3.0"])
|
169
|
+
s.add_dependency(%q<cucumber>, [">= 0.6.2"])
|
145
170
|
s.add_dependency(%q<rake-compiler>, [">= 0.7.0"])
|
171
|
+
s.add_dependency(%q<albacore>, [">= 0.1.0"])
|
146
172
|
end
|
147
173
|
else
|
148
174
|
s.add_dependency(%q<trollop>, [">= 1.15"])
|
149
|
-
s.add_dependency(%q<rspec>, [">= 1.
|
150
|
-
s.add_dependency(%q<cucumber>, [">= 0.
|
175
|
+
s.add_dependency(%q<rspec>, [">= 1.3.0"])
|
176
|
+
s.add_dependency(%q<cucumber>, [">= 0.6.2"])
|
151
177
|
s.add_dependency(%q<rake-compiler>, [">= 0.7.0"])
|
178
|
+
s.add_dependency(%q<albacore>, [">= 0.1.0"])
|
152
179
|
end
|
153
180
|
end
|
154
181
|
|
data/java/Gherkin.iml
CHANGED
@@ -1,24 +1,22 @@
|
|
1
1
|
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
-
<module
|
2
|
+
<module type="JAVA_MODULE" version="4">
|
3
3
|
<component name="NewModuleRootManager" inherit-compiler-output="true">
|
4
4
|
<exclude-output />
|
5
5
|
<content url="file://$MODULE_DIR$">
|
6
6
|
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
|
7
7
|
<sourceFolder url="file://$MODULE_DIR$/test" isTestSource="true" />
|
8
|
-
<excludeFolder url="file://$MODULE_DIR$/target" />
|
9
8
|
</content>
|
10
9
|
<orderEntry type="inheritedJdk" />
|
11
10
|
<orderEntry type="sourceFolder" forTests="false" />
|
12
11
|
<orderEntry type="module-library" scope="TEST">
|
13
12
|
<library>
|
14
13
|
<CLASSES>
|
15
|
-
<root url="jar://$APPLICATION_HOME_DIR$/lib/junit-4.
|
14
|
+
<root url="jar://$APPLICATION_HOME_DIR$/lib/junit-4.7.jar!/" />
|
16
15
|
</CLASSES>
|
17
16
|
<JAVADOC />
|
18
17
|
<SOURCES />
|
19
18
|
</library>
|
20
19
|
</orderEntry>
|
21
|
-
<orderEntry type="library" scope="TEST" name="Mockito" level="application" />
|
22
20
|
</component>
|
23
21
|
</module>
|
24
22
|
|
data/java/build.xml
CHANGED
@@ -8,6 +8,9 @@
|
|
8
8
|
<jar destfile="${basedir}/../lib/gherkin.jar">
|
9
9
|
<fileset dir="${basedir}/target/classes" />
|
10
10
|
<fileset dir="${basedir}/../lib" includes="gherkin/parser/*.txt" />
|
11
|
+
<manifest>
|
12
|
+
<attribute name="Main-Class" value="gherkin.Main" />
|
13
|
+
</manifest>
|
11
14
|
</jar>
|
12
15
|
</target>
|
13
16
|
</project>
|
@@ -17,14 +17,17 @@ public class FixJava {
|
|
17
17
|
return sb.toString();
|
18
18
|
}
|
19
19
|
|
20
|
-
public static String
|
21
|
-
Reader
|
20
|
+
public static String readResource(String filePath) throws IOException {
|
21
|
+
Reader reader = new InputStreamReader(FixJava.class.getResourceAsStream(filePath));
|
22
|
+
return readReader(reader);
|
23
|
+
}
|
22
24
|
|
25
|
+
public static String readReader(Reader reader) throws IOException {
|
23
26
|
final char[] buffer = new char[0x10000];
|
24
27
|
StringBuilder sb = new StringBuilder();
|
25
28
|
int read;
|
26
29
|
do {
|
27
|
-
read =
|
30
|
+
read = reader.read(buffer, 0, buffer.length);
|
28
31
|
if (read > 0) {
|
29
32
|
sb.append(buffer, 0, read);
|
30
33
|
}
|
@@ -0,0 +1,48 @@
|
|
1
|
+
package gherkin;
|
2
|
+
|
3
|
+
import java.util.regex.Matcher;
|
4
|
+
import java.util.regex.Pattern;
|
5
|
+
|
6
|
+
public class I18nLexer implements Lexer {
|
7
|
+
private static final Pattern LANGUAGE_PATTERN = Pattern.compile("language\\s*:\\s*(.*)");
|
8
|
+
private final Listener listener;
|
9
|
+
private String i18nLanguage;
|
10
|
+
|
11
|
+
public I18nLexer(Listener listener) {
|
12
|
+
this.listener = listener;
|
13
|
+
}
|
14
|
+
|
15
|
+
/**
|
16
|
+
* @return the i18n language code from the previous scanned source.
|
17
|
+
*/
|
18
|
+
public String getI18nLanguage() {
|
19
|
+
return i18nLanguage;
|
20
|
+
}
|
21
|
+
|
22
|
+
public void scan(CharSequence source) {
|
23
|
+
createDelegate(source).scan(source);
|
24
|
+
}
|
25
|
+
|
26
|
+
private Lexer createDelegate(CharSequence source) {
|
27
|
+
i18nLanguage = lang(source);
|
28
|
+
String i18nLanguage = this.i18nLanguage.replaceAll("[\\s-]", "").toLowerCase();
|
29
|
+
String i18nLexerClassName = i18nLanguage.substring(0,1).toUpperCase() + i18nLanguage.substring(1);
|
30
|
+
String qualifiedI18nLexerClassName = "gherkin.lexer." + i18nLexerClassName;
|
31
|
+
try {
|
32
|
+
Class<?> delegateClass = Class.forName(qualifiedI18nLexerClassName);
|
33
|
+
return (Lexer) delegateClass.getConstructor(Listener.class).newInstance(listener);
|
34
|
+
} catch (Exception e) {
|
35
|
+
throw new RuntimeException("Couldn't load lexer class: " + qualifiedI18nLexerClassName, e);
|
36
|
+
}
|
37
|
+
}
|
38
|
+
|
39
|
+
private String lang(CharSequence source) {
|
40
|
+
String lineOne = source.toString().split("\\n")[0];
|
41
|
+
Matcher matcher = LANGUAGE_PATTERN.matcher(lineOne);
|
42
|
+
if(matcher.find()) {
|
43
|
+
return matcher.group(1);
|
44
|
+
} else {
|
45
|
+
return "en";
|
46
|
+
}
|
47
|
+
}
|
48
|
+
}
|