gherkin 1.0.2-java

Sign up to get free protection for your applications and to get access to all the features.
Files changed (89) hide show
  1. data/.gitignore +7 -0
  2. data/.mailmap +2 -0
  3. data/History.txt +9 -0
  4. data/LICENSE +20 -0
  5. data/README.rdoc +38 -0
  6. data/Rakefile +48 -0
  7. data/VERSION.yml +4 -0
  8. data/bin/gherkin +5 -0
  9. data/cucumber.yml +3 -0
  10. data/features/feature_parser.feature +206 -0
  11. data/features/native_lexer.feature +19 -0
  12. data/features/parser_with_native_lexer.feature +205 -0
  13. data/features/pretty_printer.feature +14 -0
  14. data/features/step_definitions/gherkin_steps.rb +34 -0
  15. data/features/step_definitions/pretty_printer_steps.rb +56 -0
  16. data/features/steps_parser.feature +46 -0
  17. data/features/support/env.rb +33 -0
  18. data/gherkin.gemspec +155 -0
  19. data/java/.gitignore +2 -0
  20. data/java/Gherkin.iml +24 -0
  21. data/java/build.xml +13 -0
  22. data/java/src/gherkin/FixJava.java +34 -0
  23. data/java/src/gherkin/Lexer.java +5 -0
  24. data/java/src/gherkin/LexingError.java +7 -0
  25. data/java/src/gherkin/Listener.java +27 -0
  26. data/java/src/gherkin/ParseError.java +22 -0
  27. data/java/src/gherkin/Parser.java +185 -0
  28. data/java/src/gherkin/lexer/.gitignore +1 -0
  29. data/java/src/gherkin/parser/StateMachineReader.java +62 -0
  30. data/lib/.gitignore +4 -0
  31. data/lib/gherkin.rb +2 -0
  32. data/lib/gherkin/c_lexer.rb +10 -0
  33. data/lib/gherkin/cli/main.rb +34 -0
  34. data/lib/gherkin/core_ext/array.rb +5 -0
  35. data/lib/gherkin/i18n.rb +87 -0
  36. data/lib/gherkin/i18n.yml +535 -0
  37. data/lib/gherkin/i18n_lexer.rb +29 -0
  38. data/lib/gherkin/java_lexer.rb +10 -0
  39. data/lib/gherkin/lexer.rb +44 -0
  40. data/lib/gherkin/parser.rb +19 -0
  41. data/lib/gherkin/parser/meta.txt +4 -0
  42. data/lib/gherkin/parser/root.txt +9 -0
  43. data/lib/gherkin/parser/steps.txt +3 -0
  44. data/lib/gherkin/rb_lexer.rb +10 -0
  45. data/lib/gherkin/rb_lexer/.gitignore +1 -0
  46. data/lib/gherkin/rb_lexer/README.rdoc +8 -0
  47. data/lib/gherkin/rb_parser.rb +117 -0
  48. data/lib/gherkin/tools.rb +8 -0
  49. data/lib/gherkin/tools/files.rb +30 -0
  50. data/lib/gherkin/tools/pretty_listener.rb +84 -0
  51. data/lib/gherkin/tools/reformat.rb +19 -0
  52. data/lib/gherkin/tools/stats.rb +21 -0
  53. data/lib/gherkin/tools/stats_listener.rb +50 -0
  54. data/nativegems.sh +5 -0
  55. data/ragel/i18n/.gitignore +1 -0
  56. data/ragel/lexer.c.rl.erb +403 -0
  57. data/ragel/lexer.java.rl.erb +200 -0
  58. data/ragel/lexer.rb.rl.erb +171 -0
  59. data/ragel/lexer_common.rl.erb +46 -0
  60. data/spec/gherkin/c_lexer_spec.rb +21 -0
  61. data/spec/gherkin/fixtures/1.feature +8 -0
  62. data/spec/gherkin/fixtures/complex.feature +43 -0
  63. data/spec/gherkin/fixtures/i18n_fr.feature +13 -0
  64. data/spec/gherkin/fixtures/i18n_no.feature +6 -0
  65. data/spec/gherkin/fixtures/i18n_zh-CN.feature +8 -0
  66. data/spec/gherkin/fixtures/simple.feature +3 -0
  67. data/spec/gherkin/fixtures/simple_with_comments.feature +7 -0
  68. data/spec/gherkin/fixtures/simple_with_tags.feature +11 -0
  69. data/spec/gherkin/i18n_lexer_spec.rb +22 -0
  70. data/spec/gherkin/i18n_spec.rb +57 -0
  71. data/spec/gherkin/java_lexer_spec.rb +20 -0
  72. data/spec/gherkin/parser_spec.rb +28 -0
  73. data/spec/gherkin/rb_lexer_spec.rb +18 -0
  74. data/spec/gherkin/sexp_recorder.rb +29 -0
  75. data/spec/gherkin/shared/lexer_spec.rb +433 -0
  76. data/spec/gherkin/shared/py_string_spec.rb +124 -0
  77. data/spec/gherkin/shared/table_spec.rb +97 -0
  78. data/spec/gherkin/shared/tags_spec.rb +50 -0
  79. data/spec/spec_helper.rb +53 -0
  80. data/tasks/bench.rake +186 -0
  81. data/tasks/bench/feature_builder.rb +49 -0
  82. data/tasks/bench/generated/.gitignore +1 -0
  83. data/tasks/bench/null_listener.rb +4 -0
  84. data/tasks/compile.rake +70 -0
  85. data/tasks/cucumber.rake +20 -0
  86. data/tasks/ragel_task.rb +70 -0
  87. data/tasks/rdoc.rake +12 -0
  88. data/tasks/rspec.rake +15 -0
  89. metadata +196 -0
@@ -0,0 +1,49 @@
1
+ class StepsBuilder
2
+ def initialize
3
+ @steps = []
4
+ end
5
+
6
+ def step(content, generator)
7
+ @steps << " Given #{content}"
8
+ if(rand(5) == 0)
9
+ cols = rand(8) + 1
10
+ rows = rand(10)
11
+ rows.times do
12
+ row = " |"
13
+ cols.times do
14
+ row << generator.table_cell << "|"
15
+ end
16
+ @steps << row
17
+ end
18
+ end
19
+ end
20
+
21
+ def to_s
22
+ @steps.join("\n")
23
+ end
24
+ end
25
+
26
+ class FeatureBuilder
27
+ def initialize(name, &block)
28
+ @name = name
29
+ @scenarios = {}
30
+ block.call(self)
31
+ end
32
+
33
+ def scenario(name, &block)
34
+ @scenarios[name] = StepsBuilder.new
35
+ block.call(@scenarios[name])
36
+ end
37
+
38
+ def to_s
39
+ str = "Feature: #{@name}\n"
40
+ @scenarios.each do |scenario, steps|
41
+ str += "\n"
42
+ str += " Scenario: #{scenario}\n"
43
+ str += steps.to_s
44
+ str += "\n"
45
+ end
46
+ str
47
+ end
48
+ end
49
+
@@ -0,0 +1 @@
1
+ *.feature
@@ -0,0 +1,4 @@
1
+ class NullListener
2
+ def method_missing(*args)
3
+ end
4
+ end
@@ -0,0 +1,70 @@
1
+ require File.dirname(__FILE__) + '/ragel_task'
2
+ require 'gherkin/i18n'
3
+
4
+ CLEAN.include [
5
+ 'pkg', 'tmp',
6
+ '**/*.{o,bundle,jar,so,obj,pdb,lib,def,exp,log}', 'ext',
7
+ 'java/target',
8
+ 'ragel/i18n/*.rl',
9
+ 'lib/gherkin/rb_lexer/*.rb',
10
+ 'ext/**/*.c',
11
+ 'java/src/gherkin/lexer/*.java'
12
+ ]
13
+
14
+ desc "Compile the Java extensions"
15
+ task :jar do
16
+ sh("ant -f java/build.xml")
17
+ end
18
+
19
+ Gherkin::I18n.all.each do |i18n|
20
+ java = RagelTask.new('java', i18n)
21
+ rb = RagelTask.new('rb', i18n)
22
+
23
+ task :jar => java.target
24
+ task :jar => rb.target
25
+
26
+ begin
27
+ unless defined?(JRUBY_VERSION)
28
+ require 'rake/extensiontask'
29
+
30
+ c = RagelTask.new('c', i18n)
31
+
32
+ extconf = "ext/gherkin_lexer_#{i18n.sanitized_key}/extconf.rb"
33
+ file extconf do
34
+ FileUtils.mkdir(File.dirname(extconf)) unless File.directory?(File.dirname(extconf))
35
+ File.open(extconf, "w") do |io|
36
+ io.write(<<-EOF)
37
+ require 'mkmf'
38
+ $CFLAGS << ' -O0 -Wall -Werror'
39
+ dir_config("gherkin_lexer_#{i18n.sanitized_key}")
40
+ have_library("c", "main")
41
+ create_makefile("gherkin_lexer_#{i18n.sanitized_key}")
42
+ EOF
43
+ end
44
+ end
45
+
46
+ Rake::ExtensionTask.new("gherkin_lexer_#{i18n.sanitized_key}") do |ext|
47
+ if ENV['RUBY_CC_VERSION']
48
+ ext.cross_compile = true
49
+ ext.cross_platform = 'i386-mingw32'
50
+ end
51
+ end
52
+
53
+ # The way tasks are defined with compile:xxx (but without namespace) in rake-compiler forces us
54
+ # to use these hacks for setting up dependencies. Ugly!
55
+ Rake::Task["compile:gherkin_lexer_#{i18n.sanitized_key}"].prerequisites.unshift(extconf)
56
+ Rake::Task["compile:gherkin_lexer_#{i18n.sanitized_key}"].prerequisites.unshift(c.target)
57
+ Rake::Task["compile:gherkin_lexer_#{i18n.sanitized_key}"].prerequisites.unshift(rb.target)
58
+
59
+ Rake::Task["compile"].prerequisites.unshift(extconf)
60
+ Rake::Task["compile"].prerequisites.unshift(c.target)
61
+ Rake::Task["compile"].prerequisites.unshift(rb.target)
62
+ end
63
+ rescue LoadError
64
+ unless defined?($c_warned)
65
+ warn "WARNING: Rake::ExtensionTask not installed. Skipping C compilation."
66
+ $c_warned = true
67
+ task :compile # no-op
68
+ end
69
+ end
70
+ end
@@ -0,0 +1,20 @@
1
+ require 'cucumber/rake/task'
2
+
3
+ Cucumber::Rake::Task.new(:cucumber) do |t|
4
+ t.cucumber_opts = "--profile default"
5
+ end
6
+ task :cucumber => [:check_dependencies]
7
+
8
+ namespace :cucumber do
9
+ Cucumber::Rake::Task.new(:rcov, "Run Cucumber using RCov") do |t|
10
+ t.cucumber_opts = "--profile default"
11
+ t.rcov = true
12
+ t.rcov_opts = %w{--exclude spec\/}
13
+ end
14
+
15
+ Cucumber::Rake::Task.new(:native_lexer, "Run Native lexer Cucumber features") do |t|
16
+ t.cucumber_opts = "--profile native_lexer"
17
+ end
18
+ task :native_lexer => [:check_dependencies, :clean, :compile]
19
+ end
20
+
@@ -0,0 +1,70 @@
1
+ require 'yaml'
2
+ require 'erb'
3
+
4
+ class RagelTask
5
+ RL_OUTPUT_DIR = File.dirname(__FILE__) + "/../ragel/i18n"
6
+
7
+ def initialize(lang, i18n)
8
+ @lang = lang
9
+ @i18n = i18n
10
+ define_tasks
11
+ end
12
+
13
+ def define_tasks
14
+ file target => [lang_ragel, common_ragel] do
15
+ mkdir_p(File.dirname(target)) unless File.directory?(File.dirname(target))
16
+ sh "ragel #{flags} #{lang_ragel} -o #{target}"
17
+ end
18
+
19
+ file lang_ragel => lang_erb do
20
+ write(ERB.new(IO.read(lang_erb)).result(binding), lang_ragel)
21
+ end
22
+
23
+ file common_ragel => common_erb do
24
+ write(ERB.new(IO.read(common_erb)).result(binding), common_ragel)
25
+ end
26
+ end
27
+
28
+ def target
29
+ {
30
+ 'c' => "ext/gherkin_lexer_#{@i18n.sanitized_key}/gherkin_lexer_#{@i18n.sanitized_key}.c",
31
+ 'java' => "java/src/gherkin/lexer/#{@i18n.sanitized_key.capitalize}.java",
32
+ 'rb' => "lib/gherkin/rb_lexer/#{@i18n.sanitized_key}.rb"
33
+ }[@lang]
34
+ end
35
+
36
+ def common_ragel
37
+ RL_OUTPUT_DIR + "/lexer_common.#{@i18n.sanitized_key}.rl"
38
+ end
39
+
40
+ def common_erb
41
+ File.dirname(__FILE__) + '/../ragel/lexer_common.rl.erb'
42
+ end
43
+
44
+ def lang_ragel
45
+ RL_OUTPUT_DIR + "/#{@i18n.sanitized_key}.#{@lang}.rl"
46
+ end
47
+
48
+ def lang_erb
49
+ File.dirname(__FILE__) + "/../ragel/lexer.#{@lang}.rl.erb"
50
+ end
51
+
52
+ def flags
53
+ {
54
+ 'c' => '-C',
55
+ 'java' => '-J',
56
+ 'rb' => '-R'
57
+ }[@lang]
58
+ end
59
+
60
+ def write(content, filename)
61
+ mkdir_p(File.dirname(filename)) unless File.directory?(File.dirname(filename))
62
+ File.open(filename, "wb") do |file|
63
+ file.write(content)
64
+ end
65
+ end
66
+
67
+ def ragel_list(keywords)
68
+ "(#{keywords.map{|keyword| %{"#{keyword}"}}.join(' | ')})"
69
+ end
70
+ end
@@ -0,0 +1,12 @@
1
+ require 'rake/rdoctask'
2
+
3
+ Rake::RDocTask.new do |rdoc|
4
+ config = YAML.load_file('VERSION.yml')
5
+ version = "#{config[:major]}.#{config[:minor]}.#{config[:patch]}"
6
+
7
+ rdoc.rdoc_dir = 'rdoc'
8
+ rdoc.title = "Gherkin #{version}"
9
+ rdoc.rdoc_files.include('README.rdoc')
10
+ rdoc.rdoc_files.include('lib/**/*.rb')
11
+ rdoc.rdoc_files.exclude('lib/gherkin/lexer')
12
+ end
@@ -0,0 +1,15 @@
1
+ require 'spec/rake/spectask'
2
+
3
+ Spec::Rake::SpecTask.new(:spec) do |spec|
4
+ spec.libs << 'lib' << 'spec'
5
+ spec.spec_opts << '--color'
6
+ end
7
+ task :spec => [:check_dependencies]
8
+
9
+ Spec::Rake::SpecTask.new(:rcov) do |spec|
10
+ spec.libs << 'lib' << 'spec'
11
+ spec.spec_opts << '--color'
12
+ spec.pattern = 'spec/**/*_spec.rb'
13
+ spec.rcov = true
14
+ spec.rcov_opts = %w{--exclude spec\/}
15
+ end
metadata ADDED
@@ -0,0 +1,196 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: gherkin
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.2
5
+ platform: java
6
+ authors:
7
+ - Mike Sassak
8
+ - Gregory Hnatiuk
9
+ - "Aslak Helles\xC3\xB8y"
10
+ autorequire:
11
+ bindir: bin
12
+ cert_chain: []
13
+
14
+ date: 2009-12-30 00:00:00 +01:00
15
+ default_executable: gherkin
16
+ dependencies:
17
+ - !ruby/object:Gem::Dependency
18
+ name: trollop
19
+ type: :runtime
20
+ version_requirement:
21
+ version_requirements: !ruby/object:Gem::Requirement
22
+ requirements:
23
+ - - ">="
24
+ - !ruby/object:Gem::Version
25
+ version: "1.15"
26
+ version:
27
+ - !ruby/object:Gem::Dependency
28
+ name: rspec
29
+ type: :development
30
+ version_requirement:
31
+ version_requirements: !ruby/object:Gem::Requirement
32
+ requirements:
33
+ - - ">="
34
+ - !ruby/object:Gem::Version
35
+ version: 1.2.9
36
+ version:
37
+ - !ruby/object:Gem::Dependency
38
+ name: cucumber
39
+ type: :development
40
+ version_requirement:
41
+ version_requirements: !ruby/object:Gem::Requirement
42
+ requirements:
43
+ - - ">="
44
+ - !ruby/object:Gem::Version
45
+ version: 0.5.1
46
+ version:
47
+ - !ruby/object:Gem::Dependency
48
+ name: rake-compiler
49
+ type: :development
50
+ version_requirement:
51
+ version_requirements: !ruby/object:Gem::Requirement
52
+ requirements:
53
+ - - ">="
54
+ - !ruby/object:Gem::Version
55
+ version: 0.7.0
56
+ version:
57
+ description: A fast Gherkin lexer/parser based on the Ragel State Machine Compiler.
58
+ email: cukes@googlegroups.com
59
+ executables:
60
+ - gherkin
61
+ extensions: []
62
+
63
+ extra_rdoc_files:
64
+ - LICENSE
65
+ - README.rdoc
66
+ files:
67
+ - .gitignore
68
+ - .mailmap
69
+ - History.txt
70
+ - LICENSE
71
+ - README.rdoc
72
+ - Rakefile
73
+ - VERSION.yml
74
+ - bin/gherkin
75
+ - cucumber.yml
76
+ - features/feature_parser.feature
77
+ - features/native_lexer.feature
78
+ - features/parser_with_native_lexer.feature
79
+ - features/pretty_printer.feature
80
+ - features/step_definitions/gherkin_steps.rb
81
+ - features/step_definitions/pretty_printer_steps.rb
82
+ - features/steps_parser.feature
83
+ - features/support/env.rb
84
+ - gherkin.gemspec
85
+ - java/.gitignore
86
+ - java/Gherkin.iml
87
+ - java/build.xml
88
+ - java/src/gherkin/FixJava.java
89
+ - java/src/gherkin/Lexer.java
90
+ - java/src/gherkin/LexingError.java
91
+ - java/src/gherkin/Listener.java
92
+ - java/src/gherkin/ParseError.java
93
+ - java/src/gherkin/Parser.java
94
+ - java/src/gherkin/lexer/.gitignore
95
+ - java/src/gherkin/parser/StateMachineReader.java
96
+ - lib/.gitignore
97
+ - lib/gherkin.jar
98
+ - lib/gherkin.rb
99
+ - lib/gherkin/c_lexer.rb
100
+ - lib/gherkin/cli/main.rb
101
+ - lib/gherkin/core_ext/array.rb
102
+ - lib/gherkin/i18n.rb
103
+ - lib/gherkin/i18n.yml
104
+ - lib/gherkin/i18n_lexer.rb
105
+ - lib/gherkin/java_lexer.rb
106
+ - lib/gherkin/lexer.rb
107
+ - lib/gherkin/parser.rb
108
+ - lib/gherkin/parser/meta.txt
109
+ - lib/gherkin/parser/root.txt
110
+ - lib/gherkin/parser/steps.txt
111
+ - lib/gherkin/rb_lexer.rb
112
+ - lib/gherkin/rb_lexer/.gitignore
113
+ - lib/gherkin/rb_lexer/README.rdoc
114
+ - lib/gherkin/rb_parser.rb
115
+ - lib/gherkin/tools.rb
116
+ - lib/gherkin/tools/files.rb
117
+ - lib/gherkin/tools/pretty_listener.rb
118
+ - lib/gherkin/tools/reformat.rb
119
+ - lib/gherkin/tools/stats.rb
120
+ - lib/gherkin/tools/stats_listener.rb
121
+ - nativegems.sh
122
+ - ragel/i18n/.gitignore
123
+ - ragel/lexer.c.rl.erb
124
+ - ragel/lexer.java.rl.erb
125
+ - ragel/lexer.rb.rl.erb
126
+ - ragel/lexer_common.rl.erb
127
+ - spec/gherkin/c_lexer_spec.rb
128
+ - spec/gherkin/fixtures/1.feature
129
+ - spec/gherkin/fixtures/complex.feature
130
+ - spec/gherkin/fixtures/i18n_fr.feature
131
+ - spec/gherkin/fixtures/i18n_no.feature
132
+ - spec/gherkin/fixtures/i18n_zh-CN.feature
133
+ - spec/gherkin/fixtures/simple.feature
134
+ - spec/gherkin/fixtures/simple_with_comments.feature
135
+ - spec/gherkin/fixtures/simple_with_tags.feature
136
+ - spec/gherkin/i18n_lexer_spec.rb
137
+ - spec/gherkin/i18n_spec.rb
138
+ - spec/gherkin/java_lexer_spec.rb
139
+ - spec/gherkin/parser_spec.rb
140
+ - spec/gherkin/rb_lexer_spec.rb
141
+ - spec/gherkin/sexp_recorder.rb
142
+ - spec/gherkin/shared/lexer_spec.rb
143
+ - spec/gherkin/shared/py_string_spec.rb
144
+ - spec/gherkin/shared/table_spec.rb
145
+ - spec/gherkin/shared/tags_spec.rb
146
+ - spec/spec_helper.rb
147
+ - tasks/bench.rake
148
+ - tasks/bench/feature_builder.rb
149
+ - tasks/bench/generated/.gitignore
150
+ - tasks/bench/null_listener.rb
151
+ - tasks/compile.rake
152
+ - tasks/cucumber.rake
153
+ - tasks/ragel_task.rb
154
+ - tasks/rdoc.rake
155
+ - tasks/rspec.rake
156
+ has_rdoc: true
157
+ homepage: http://github.com/aslakhellesoy/gherkin
158
+ licenses: []
159
+
160
+ post_install_message:
161
+ rdoc_options:
162
+ - --charset=UTF-8
163
+ require_paths:
164
+ - lib
165
+ required_ruby_version: !ruby/object:Gem::Requirement
166
+ requirements:
167
+ - - ">="
168
+ - !ruby/object:Gem::Version
169
+ version: "0"
170
+ version:
171
+ required_rubygems_version: !ruby/object:Gem::Requirement
172
+ requirements:
173
+ - - ">="
174
+ - !ruby/object:Gem::Version
175
+ version: "0"
176
+ version:
177
+ requirements: []
178
+
179
+ rubyforge_project:
180
+ rubygems_version: 1.3.5
181
+ signing_key:
182
+ specification_version: 3
183
+ summary: Fast Gherkin lexer/parser
184
+ test_files:
185
+ - spec/gherkin/c_lexer_spec.rb
186
+ - spec/gherkin/i18n_lexer_spec.rb
187
+ - spec/gherkin/i18n_spec.rb
188
+ - spec/gherkin/java_lexer_spec.rb
189
+ - spec/gherkin/parser_spec.rb
190
+ - spec/gherkin/rb_lexer_spec.rb
191
+ - spec/gherkin/sexp_recorder.rb
192
+ - spec/gherkin/shared/lexer_spec.rb
193
+ - spec/gherkin/shared/py_string_spec.rb
194
+ - spec/gherkin/shared/table_spec.rb
195
+ - spec/gherkin/shared/tags_spec.rb
196
+ - spec/spec_helper.rb