gherkin 0.0.3-universal-java-1.5
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +8 -0
- data/LICENSE +20 -0
- data/README.rdoc +47 -0
- data/Rakefile +48 -0
- data/VERSION.yml +4 -0
- data/bin/gherkin +10 -0
- data/cucumber.yml +3 -0
- data/ext/gherkin_lexer/.gitignore +6 -0
- data/ext/gherkin_lexer/extconf.rb +6 -0
- data/features/feature_parser.feature +206 -0
- data/features/native_lexer.feature +19 -0
- data/features/parser_with_native_lexer.feature +205 -0
- data/features/pretty_printer.feature +11 -0
- data/features/step_definitions/gherkin_steps.rb +34 -0
- data/features/step_definitions/pretty_printer_steps.rb +51 -0
- data/features/steps_parser.feature +46 -0
- data/features/support/env.rb +33 -0
- data/gherkin.gemspec +177 -0
- data/java/.gitignore +2 -0
- data/java/Gherkin.iml +24 -0
- data/java/build.xml +13 -0
- data/java/src/gherkin/FixJava.java +34 -0
- data/java/src/gherkin/Lexer.java +5 -0
- data/java/src/gherkin/LexingError.java +7 -0
- data/java/src/gherkin/Listener.java +27 -0
- data/java/src/gherkin/ParseError.java +22 -0
- data/java/src/gherkin/Parser.java +185 -0
- data/java/src/gherkin/lexer/.gitignore +1 -0
- data/java/src/gherkin/parser/StateMachineReader.java +62 -0
- data/lib/.gitignore +2 -0
- data/lib/gherkin.rb +2 -0
- data/lib/gherkin/c_lexer.rb +10 -0
- data/lib/gherkin/i18n.yml +535 -0
- data/lib/gherkin/i18n_lexer.rb +29 -0
- data/lib/gherkin/java_lexer.rb +10 -0
- data/lib/gherkin/lexer.rb +42 -0
- data/lib/gherkin/parser.rb +19 -0
- data/lib/gherkin/parser/meta.txt +4 -0
- data/lib/gherkin/parser/root.txt +9 -0
- data/lib/gherkin/parser/steps.txt +3 -0
- data/lib/gherkin/rb_lexer.rb +9 -0
- data/lib/gherkin/rb_lexer/.gitignore +1 -0
- data/lib/gherkin/rb_lexer/README.rdoc +8 -0
- data/lib/gherkin/rb_parser.rb +117 -0
- data/lib/gherkin/tools/pretty_printer.rb +77 -0
- data/ragel/i18n/.gitignore +1 -0
- data/ragel/lexer.c.rl.erb +385 -0
- data/ragel/lexer.java.rl.erb +198 -0
- data/ragel/lexer.rb.rl.erb +172 -0
- data/ragel/lexer_common.rl.erb +46 -0
- data/spec/gherkin/c_lexer_spec.rb +21 -0
- data/spec/gherkin/fixtures/complex.feature +43 -0
- data/spec/gherkin/fixtures/i18n_fr.feature +13 -0
- data/spec/gherkin/fixtures/i18n_no.feature +6 -0
- data/spec/gherkin/fixtures/i18n_zh-CN.feature +8 -0
- data/spec/gherkin/fixtures/simple.feature +3 -0
- data/spec/gherkin/fixtures/simple_with_comments.feature +7 -0
- data/spec/gherkin/fixtures/simple_with_tags.feature +11 -0
- data/spec/gherkin/i18n_spec.rb +57 -0
- data/spec/gherkin/java_lexer_spec.rb +20 -0
- data/spec/gherkin/parser_spec.rb +28 -0
- data/spec/gherkin/rb_lexer_spec.rb +18 -0
- data/spec/gherkin/sexp_recorder.rb +29 -0
- data/spec/gherkin/shared/lexer_spec.rb +420 -0
- data/spec/gherkin/shared/py_string_spec.rb +112 -0
- data/spec/gherkin/shared/table_spec.rb +97 -0
- data/spec/gherkin/shared/tags_spec.rb +50 -0
- data/spec/spec_helper.rb +53 -0
- data/tasks/bench.rake +176 -0
- data/tasks/bench/feature_builder.rb +49 -0
- data/tasks/bench/generated/.gitignore +1 -0
- data/tasks/bench/null_listener.rb +4 -0
- data/tasks/cucumber.rake +20 -0
- data/tasks/ext.rake +49 -0
- data/tasks/ragel.rake +94 -0
- data/tasks/rdoc.rake +12 -0
- data/tasks/rspec.rake +15 -0
- metadata +204 -0
@@ -0,0 +1,11 @@
|
|
1
|
+
Feature: Pretty printer
|
2
|
+
In order to have pretty gherkin
|
3
|
+
I want to verify that all prettified cucumber features parse OK
|
4
|
+
|
5
|
+
Scenario: Parse all the features in Cucumber
|
6
|
+
Given I have Cucumber's home dir defined in CUCUMBER_HOME
|
7
|
+
When I find all of the .feature files
|
8
|
+
And I parse the prettified representation of each of them
|
9
|
+
# Of course, we don't really want all those errors, but these are the current ones.
|
10
|
+
Then the following files should have errors:
|
11
|
+
| Path | Error |
|
@@ -0,0 +1,34 @@
|
|
1
|
+
Given /^a "([^\"]*)", "([^\"]*)" "([^\"]*)" parser$/ do |i18n_language, impl, parser_name|
|
2
|
+
parser = Gherkin::Parser.new(@listener, false, parser_name)
|
3
|
+
programming_language = {
|
4
|
+
'ruby' => 'rb',
|
5
|
+
'native' => (defined?(JRUBY_VERSION) ? 'java' : 'c')
|
6
|
+
}[impl]
|
7
|
+
@lexer = Gherkin::Lexer.send(programming_language)[i18n_language].new(parser)
|
8
|
+
end
|
9
|
+
|
10
|
+
Given "the following text is parsed:" do |text|
|
11
|
+
@lexer.scan(text)
|
12
|
+
end
|
13
|
+
|
14
|
+
Then "there should be no parse errors" do
|
15
|
+
@listener.errors.should == []
|
16
|
+
end
|
17
|
+
|
18
|
+
Then /^there should be a parse error on (line \d+)$/ do |line|
|
19
|
+
@listener.line(line).should include(:syntax_error, line)
|
20
|
+
end
|
21
|
+
|
22
|
+
Then /^there should be parse errors on (lines .*)$/ do |lines|
|
23
|
+
lines.each do |line|
|
24
|
+
Then "there should be a parse error on line #{line}"
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
Transform /^line \d+$/ do |step_arg|
|
29
|
+
tr_line_number(step_arg)
|
30
|
+
end
|
31
|
+
|
32
|
+
Transform /^lines .*$/ do |step_arg|
|
33
|
+
tr_line_numbers(step_arg)
|
34
|
+
end
|
@@ -0,0 +1,51 @@
|
|
1
|
+
require 'stringio'
|
2
|
+
require 'gherkin/tools/pretty_printer'
|
3
|
+
|
4
|
+
module PrettyPlease
|
5
|
+
def pretty(source)
|
6
|
+
io = StringIO.new
|
7
|
+
listener = Gherkin::Tools::PrettyPrinter.new(io)
|
8
|
+
parser = Gherkin::Parser.new(listener, true)
|
9
|
+
lexer = Gherkin::I18nLexer.new(parser)
|
10
|
+
lexer.scan(source)
|
11
|
+
io.rewind
|
12
|
+
io.read
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
World(PrettyPlease)
|
17
|
+
|
18
|
+
Given /^I have Cucumber's home dir defined in CUCUMBER_HOME$/ do
|
19
|
+
@cucumber_home = ENV['CUCUMBER_HOME']
|
20
|
+
raise "No CUCUMBER_HOME" if @cucumber_home.nil?
|
21
|
+
end
|
22
|
+
|
23
|
+
When /^I find all of the \.feature files$/ do
|
24
|
+
@features = Dir["#{@cucumber_home}/**/*.feature"].sort
|
25
|
+
end
|
26
|
+
|
27
|
+
When /^I parse the prettified representation of each of them$/ do
|
28
|
+
@errors = [['Path', 'Error']]
|
29
|
+
@features.each do |feature|
|
30
|
+
begin
|
31
|
+
pretty1 = pretty(IO.read(feature))
|
32
|
+
pretty2 = pretty(pretty1)
|
33
|
+
|
34
|
+
pretty2.should == pretty1
|
35
|
+
rescue Spec::Expectations::ExpectationNotMetError => e
|
36
|
+
announce "========== #{feature}:"
|
37
|
+
if(e.message =~ /(@@.*)/m)
|
38
|
+
announce $1
|
39
|
+
else
|
40
|
+
announce "??? NO DIFF ???"
|
41
|
+
end
|
42
|
+
@errors << [feature, "See announced diff"]
|
43
|
+
rescue => e
|
44
|
+
@errors << [feature, e.message]
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
Then /^the following files should have errors:$/ do |table|
|
50
|
+
table.diff!(@errors)
|
51
|
+
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
Feature: Gherkin Steps parser
|
2
|
+
In order to save time and make my features clearer
|
3
|
+
As a Cucumber developer
|
4
|
+
I want a steps parser to make writing compound steps easier
|
5
|
+
|
6
|
+
Background:
|
7
|
+
Given a "en", "ruby" "steps" parser
|
8
|
+
|
9
|
+
Scenario: Parsing steps
|
10
|
+
Given the following text is parsed:
|
11
|
+
"""
|
12
|
+
Given a one step
|
13
|
+
And a two step
|
14
|
+
\"\"\"
|
15
|
+
Here is a multiline string
|
16
|
+
That follows a step
|
17
|
+
With an argument #{arg}
|
18
|
+
\"\"\"
|
19
|
+
And a one two three step
|
20
|
+
When another step
|
21
|
+
Then there should be a table
|
22
|
+
| one | two | three |
|
23
|
+
| foo | bar | #{arg} |
|
24
|
+
"""
|
25
|
+
Then there should be no parse errors
|
26
|
+
|
27
|
+
Scenario: Trying to parse a full feature with the step parser
|
28
|
+
Given the following text is parsed:
|
29
|
+
"""
|
30
|
+
Feature: A Feature
|
31
|
+
Scenario: Yes, there is one
|
32
|
+
Given I have a step
|
33
|
+
When I execute this step
|
34
|
+
Then something should happen
|
35
|
+
"""
|
36
|
+
Then there should be parse errors on lines 1 and 2
|
37
|
+
|
38
|
+
Scenario: Tags
|
39
|
+
Given the following text is parsed:
|
40
|
+
"""
|
41
|
+
@a_tag
|
42
|
+
Given a step
|
43
|
+
When I trip
|
44
|
+
Then I should sign up for dancing lessons
|
45
|
+
"""
|
46
|
+
Then there should be a parse error on line 1
|
@@ -0,0 +1,33 @@
|
|
1
|
+
# I'm sure there's a better way than this...
|
2
|
+
%w{/../../lib /../../spec/gherkin}.each do |path|
|
3
|
+
$LOAD_PATH << File.expand_path(File.dirname(__FILE__) + path)
|
4
|
+
end
|
5
|
+
|
6
|
+
require 'gherkin'
|
7
|
+
require "sexp_recorder"
|
8
|
+
|
9
|
+
module TransformHelpers
|
10
|
+
def tr_line_number(step_arg)
|
11
|
+
/(\d+)$/.match(step_arg)[0].to_i
|
12
|
+
end
|
13
|
+
|
14
|
+
def tr_line_numbers(step_arg)
|
15
|
+
if step_arg =~ /through/
|
16
|
+
Range.new(*step_arg.scan(/\d+/).collect { |i| i.to_i })
|
17
|
+
else
|
18
|
+
step_arg.scan(/\d+/).collect { |i| i.to_i }
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
class GherkinWorld
|
24
|
+
include TransformHelpers
|
25
|
+
|
26
|
+
def initialize
|
27
|
+
@listener = Gherkin::SexpRecorder.new
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
World do
|
32
|
+
GherkinWorld.new
|
33
|
+
end
|
data/gherkin.gemspec
ADDED
@@ -0,0 +1,177 @@
|
|
1
|
+
# Generated by jeweler
|
2
|
+
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
|
4
|
+
# -*- encoding: utf-8 -*-
|
5
|
+
|
6
|
+
Gem::Specification.new do |s|
|
7
|
+
s.name = %q{gherkin}
|
8
|
+
s.version = "0.0.3"
|
9
|
+
s.platform = %q{universal-java-1.5}
|
10
|
+
|
11
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
12
|
+
s.authors = ["Mike Sassak", "Gregory Hnatiuk", "Aslak Helles\303\270y"]
|
13
|
+
s.date = %q{2009-11-25}
|
14
|
+
s.default_executable = %q{gherkin}
|
15
|
+
s.description = %q{A fast Gherkin lexer in Ragel}
|
16
|
+
s.email = %q{cukes@googlegroups.com}
|
17
|
+
s.executables = ["gherkin"]
|
18
|
+
s.extra_rdoc_files = [
|
19
|
+
"LICENSE",
|
20
|
+
"README.rdoc"
|
21
|
+
]
|
22
|
+
s.files = [
|
23
|
+
".gitignore",
|
24
|
+
"LICENSE",
|
25
|
+
"README.rdoc",
|
26
|
+
"Rakefile",
|
27
|
+
"VERSION.yml",
|
28
|
+
"bin/gherkin",
|
29
|
+
"cucumber.yml",
|
30
|
+
"ext/gherkin_lexer/.gitignore",
|
31
|
+
"ext/gherkin_lexer/extconf.rb",
|
32
|
+
"features/feature_parser.feature",
|
33
|
+
"features/native_lexer.feature",
|
34
|
+
"features/parser_with_native_lexer.feature",
|
35
|
+
"features/pretty_printer.feature",
|
36
|
+
"features/step_definitions/gherkin_steps.rb",
|
37
|
+
"features/step_definitions/pretty_printer_steps.rb",
|
38
|
+
"features/steps_parser.feature",
|
39
|
+
"features/support/env.rb",
|
40
|
+
"gherkin.gemspec",
|
41
|
+
"java/.gitignore",
|
42
|
+
"java/Gherkin.iml",
|
43
|
+
"java/build.xml",
|
44
|
+
"java/src/gherkin/FixJava.java",
|
45
|
+
"java/src/gherkin/Lexer.java",
|
46
|
+
"java/src/gherkin/LexingError.java",
|
47
|
+
"java/src/gherkin/Listener.java",
|
48
|
+
"java/src/gherkin/ParseError.java",
|
49
|
+
"java/src/gherkin/Parser.java",
|
50
|
+
"java/src/gherkin/lexer/.gitignore",
|
51
|
+
"java/src/gherkin/parser/StateMachineReader.java",
|
52
|
+
"lib/.gitignore",
|
53
|
+
"lib/gherkin.jar",
|
54
|
+
"lib/gherkin.rb",
|
55
|
+
"lib/gherkin/c_lexer.rb",
|
56
|
+
"lib/gherkin/i18n.yml",
|
57
|
+
"lib/gherkin/i18n_lexer.rb",
|
58
|
+
"lib/gherkin/java_lexer.rb",
|
59
|
+
"lib/gherkin/lexer.rb",
|
60
|
+
"lib/gherkin/parser.rb",
|
61
|
+
"lib/gherkin/parser/meta.txt",
|
62
|
+
"lib/gherkin/parser/root.txt",
|
63
|
+
"lib/gherkin/parser/steps.txt",
|
64
|
+
"lib/gherkin/rb_lexer.rb",
|
65
|
+
"lib/gherkin/rb_lexer/.gitignore",
|
66
|
+
"lib/gherkin/rb_lexer/README.rdoc",
|
67
|
+
"lib/gherkin/rb_lexer/ar.rb",
|
68
|
+
"lib/gherkin/rb_lexer/bg.rb",
|
69
|
+
"lib/gherkin/rb_lexer/cat.rb",
|
70
|
+
"lib/gherkin/rb_lexer/cs.rb",
|
71
|
+
"lib/gherkin/rb_lexer/cy.rb",
|
72
|
+
"lib/gherkin/rb_lexer/da.rb",
|
73
|
+
"lib/gherkin/rb_lexer/de.rb",
|
74
|
+
"lib/gherkin/rb_lexer/en-au.rb",
|
75
|
+
"lib/gherkin/rb_lexer/en-lol.rb",
|
76
|
+
"lib/gherkin/rb_lexer/en-tx.rb",
|
77
|
+
"lib/gherkin/rb_lexer/en.rb",
|
78
|
+
"lib/gherkin/rb_lexer/es.rb",
|
79
|
+
"lib/gherkin/rb_lexer/et.rb",
|
80
|
+
"lib/gherkin/rb_lexer/fi.rb",
|
81
|
+
"lib/gherkin/rb_lexer/fr.rb",
|
82
|
+
"lib/gherkin/rb_lexer/he.rb",
|
83
|
+
"lib/gherkin/rb_lexer/hr.rb",
|
84
|
+
"lib/gherkin/rb_lexer/hu.rb",
|
85
|
+
"lib/gherkin/rb_lexer/id.rb",
|
86
|
+
"lib/gherkin/rb_lexer/it.rb",
|
87
|
+
"lib/gherkin/rb_lexer/ja.rb",
|
88
|
+
"lib/gherkin/rb_lexer/ko.rb",
|
89
|
+
"lib/gherkin/rb_lexer/lt.rb",
|
90
|
+
"lib/gherkin/rb_lexer/lv.rb",
|
91
|
+
"lib/gherkin/rb_lexer/nl.rb",
|
92
|
+
"lib/gherkin/rb_lexer/no.rb",
|
93
|
+
"lib/gherkin/rb_lexer/pl.rb",
|
94
|
+
"lib/gherkin/rb_lexer/pt.rb",
|
95
|
+
"lib/gherkin/rb_lexer/ro.rb",
|
96
|
+
"lib/gherkin/rb_lexer/ro2.rb",
|
97
|
+
"lib/gherkin/rb_lexer/ru.rb",
|
98
|
+
"lib/gherkin/rb_lexer/se.rb",
|
99
|
+
"lib/gherkin/rb_lexer/sk.rb",
|
100
|
+
"lib/gherkin/rb_lexer/sr-Latn.rb",
|
101
|
+
"lib/gherkin/rb_lexer/sr.rb",
|
102
|
+
"lib/gherkin/rb_lexer/tr.rb",
|
103
|
+
"lib/gherkin/rb_lexer/uz.rb",
|
104
|
+
"lib/gherkin/rb_lexer/vi.rb",
|
105
|
+
"lib/gherkin/rb_lexer/zh-CN.rb",
|
106
|
+
"lib/gherkin/rb_lexer/zh-TW.rb",
|
107
|
+
"lib/gherkin/rb_parser.rb",
|
108
|
+
"lib/gherkin/tools/pretty_printer.rb",
|
109
|
+
"ragel/i18n/.gitignore",
|
110
|
+
"ragel/lexer.c.rl.erb",
|
111
|
+
"ragel/lexer.java.rl.erb",
|
112
|
+
"ragel/lexer.rb.rl.erb",
|
113
|
+
"ragel/lexer_common.rl.erb",
|
114
|
+
"spec/gherkin/c_lexer_spec.rb",
|
115
|
+
"spec/gherkin/fixtures/complex.feature",
|
116
|
+
"spec/gherkin/fixtures/i18n_fr.feature",
|
117
|
+
"spec/gherkin/fixtures/i18n_no.feature",
|
118
|
+
"spec/gherkin/fixtures/i18n_zh-CN.feature",
|
119
|
+
"spec/gherkin/fixtures/simple.feature",
|
120
|
+
"spec/gherkin/fixtures/simple_with_comments.feature",
|
121
|
+
"spec/gherkin/fixtures/simple_with_tags.feature",
|
122
|
+
"spec/gherkin/i18n_spec.rb",
|
123
|
+
"spec/gherkin/java_lexer_spec.rb",
|
124
|
+
"spec/gherkin/parser_spec.rb",
|
125
|
+
"spec/gherkin/rb_lexer_spec.rb",
|
126
|
+
"spec/gherkin/sexp_recorder.rb",
|
127
|
+
"spec/gherkin/shared/lexer_spec.rb",
|
128
|
+
"spec/gherkin/shared/py_string_spec.rb",
|
129
|
+
"spec/gherkin/shared/table_spec.rb",
|
130
|
+
"spec/gherkin/shared/tags_spec.rb",
|
131
|
+
"spec/spec_helper.rb",
|
132
|
+
"tasks/bench.rake",
|
133
|
+
"tasks/bench/feature_builder.rb",
|
134
|
+
"tasks/bench/generated/.gitignore",
|
135
|
+
"tasks/bench/null_listener.rb",
|
136
|
+
"tasks/cucumber.rake",
|
137
|
+
"tasks/ext.rake",
|
138
|
+
"tasks/ragel.rake",
|
139
|
+
"tasks/rdoc.rake",
|
140
|
+
"tasks/rspec.rake"
|
141
|
+
]
|
142
|
+
s.homepage = %q{http://github.com/aslakhellesoy/gherkin}
|
143
|
+
s.rdoc_options = ["--charset=UTF-8"]
|
144
|
+
s.require_paths = ["lib"]
|
145
|
+
s.rubygems_version = %q{1.3.5}
|
146
|
+
s.summary = %q{Fast Gherkin lexer}
|
147
|
+
s.test_files = [
|
148
|
+
"spec/spec_helper.rb",
|
149
|
+
"spec/gherkin/c_lexer_spec.rb",
|
150
|
+
"spec/gherkin/i18n_spec.rb",
|
151
|
+
"spec/gherkin/java_lexer_spec.rb",
|
152
|
+
"spec/gherkin/parser_spec.rb",
|
153
|
+
"spec/gherkin/rb_lexer_spec.rb",
|
154
|
+
"spec/gherkin/sexp_recorder.rb",
|
155
|
+
"spec/gherkin/shared/lexer_spec.rb",
|
156
|
+
"spec/gherkin/shared/py_string_spec.rb",
|
157
|
+
"spec/gherkin/shared/table_spec.rb",
|
158
|
+
"spec/gherkin/shared/tags_spec.rb"
|
159
|
+
]
|
160
|
+
|
161
|
+
if s.respond_to? :specification_version then
|
162
|
+
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
163
|
+
s.specification_version = 3
|
164
|
+
|
165
|
+
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
166
|
+
s.add_development_dependency(%q<rspec>, ["= 1.2.9"])
|
167
|
+
s.add_development_dependency(%q<cucumber>, [">= 0"])
|
168
|
+
else
|
169
|
+
s.add_dependency(%q<rspec>, ["= 1.2.9"])
|
170
|
+
s.add_dependency(%q<cucumber>, [">= 0"])
|
171
|
+
end
|
172
|
+
else
|
173
|
+
s.add_dependency(%q<rspec>, ["= 1.2.9"])
|
174
|
+
s.add_dependency(%q<cucumber>, [">= 0"])
|
175
|
+
end
|
176
|
+
end
|
177
|
+
|
data/java/.gitignore
ADDED
data/java/Gherkin.iml
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
<module relativePaths="true" type="JAVA_MODULE" version="4">
|
3
|
+
<component name="NewModuleRootManager" inherit-compiler-output="true">
|
4
|
+
<exclude-output />
|
5
|
+
<content url="file://$MODULE_DIR$">
|
6
|
+
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
|
7
|
+
<sourceFolder url="file://$MODULE_DIR$/test" isTestSource="true" />
|
8
|
+
<excludeFolder url="file://$MODULE_DIR$/target" />
|
9
|
+
</content>
|
10
|
+
<orderEntry type="inheritedJdk" />
|
11
|
+
<orderEntry type="sourceFolder" forTests="false" />
|
12
|
+
<orderEntry type="module-library" scope="TEST">
|
13
|
+
<library>
|
14
|
+
<CLASSES>
|
15
|
+
<root url="jar://$APPLICATION_HOME_DIR$/lib/junit-4.6.jar!/" />
|
16
|
+
</CLASSES>
|
17
|
+
<JAVADOC />
|
18
|
+
<SOURCES />
|
19
|
+
</library>
|
20
|
+
</orderEntry>
|
21
|
+
<orderEntry type="library" scope="TEST" name="Mockito" level="application" />
|
22
|
+
</component>
|
23
|
+
</module>
|
24
|
+
|
data/java/build.xml
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
<project name="Gherkin" default="jar" basedir=".">
|
2
|
+
<target name="compile" description="Compile">
|
3
|
+
<mkdir dir="${basedir}/target/classes"/>
|
4
|
+
<javac srcdir="src" destdir="target/classes" debug="on"/>
|
5
|
+
</target>
|
6
|
+
|
7
|
+
<target name="jar" description="Jar" depends="compile">
|
8
|
+
<jar destfile="${basedir}/../lib/gherkin.jar">
|
9
|
+
<fileset dir="${basedir}/target/classes" />
|
10
|
+
<fileset dir="${basedir}/../lib" includes="gherkin/parser/*.txt" />
|
11
|
+
</jar>
|
12
|
+
</target>
|
13
|
+
</project>
|
@@ -0,0 +1,34 @@
|
|
1
|
+
package gherkin;
|
2
|
+
|
3
|
+
import java.io.IOException;
|
4
|
+
import java.io.InputStreamReader;
|
5
|
+
import java.io.Reader;
|
6
|
+
import java.util.List;
|
7
|
+
|
8
|
+
public class FixJava {
|
9
|
+
public static String join(List<String> strings, String separator) {
|
10
|
+
StringBuffer sb = new StringBuffer();
|
11
|
+
int i = 0;
|
12
|
+
for (String s : strings) {
|
13
|
+
if (i != 0) sb.append(separator);
|
14
|
+
sb.append(s);
|
15
|
+
i++;
|
16
|
+
}
|
17
|
+
return sb.toString();
|
18
|
+
}
|
19
|
+
|
20
|
+
public static String readResourceAsString(String filePath) throws IOException {
|
21
|
+
Reader machine = new InputStreamReader(FixJava.class.getResourceAsStream(filePath));
|
22
|
+
|
23
|
+
final char[] buffer = new char[0x10000];
|
24
|
+
StringBuilder out = new StringBuilder();
|
25
|
+
int read;
|
26
|
+
do {
|
27
|
+
read = machine.read(buffer, 0, buffer.length);
|
28
|
+
if (read > 0) {
|
29
|
+
out.append(buffer, 0, read);
|
30
|
+
}
|
31
|
+
} while (read >= 0);
|
32
|
+
return out.toString();
|
33
|
+
}
|
34
|
+
}
|