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.
Files changed (78) hide show
  1. data/.gitignore +8 -0
  2. data/LICENSE +20 -0
  3. data/README.rdoc +47 -0
  4. data/Rakefile +48 -0
  5. data/VERSION.yml +4 -0
  6. data/bin/gherkin +10 -0
  7. data/cucumber.yml +3 -0
  8. data/ext/gherkin_lexer/.gitignore +6 -0
  9. data/ext/gherkin_lexer/extconf.rb +6 -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 +11 -0
  14. data/features/step_definitions/gherkin_steps.rb +34 -0
  15. data/features/step_definitions/pretty_printer_steps.rb +51 -0
  16. data/features/steps_parser.feature +46 -0
  17. data/features/support/env.rb +33 -0
  18. data/gherkin.gemspec +177 -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 +2 -0
  31. data/lib/gherkin.rb +2 -0
  32. data/lib/gherkin/c_lexer.rb +10 -0
  33. data/lib/gherkin/i18n.yml +535 -0
  34. data/lib/gherkin/i18n_lexer.rb +29 -0
  35. data/lib/gherkin/java_lexer.rb +10 -0
  36. data/lib/gherkin/lexer.rb +42 -0
  37. data/lib/gherkin/parser.rb +19 -0
  38. data/lib/gherkin/parser/meta.txt +4 -0
  39. data/lib/gherkin/parser/root.txt +9 -0
  40. data/lib/gherkin/parser/steps.txt +3 -0
  41. data/lib/gherkin/rb_lexer.rb +9 -0
  42. data/lib/gherkin/rb_lexer/.gitignore +1 -0
  43. data/lib/gherkin/rb_lexer/README.rdoc +8 -0
  44. data/lib/gherkin/rb_parser.rb +117 -0
  45. data/lib/gherkin/tools/pretty_printer.rb +77 -0
  46. data/ragel/i18n/.gitignore +1 -0
  47. data/ragel/lexer.c.rl.erb +385 -0
  48. data/ragel/lexer.java.rl.erb +198 -0
  49. data/ragel/lexer.rb.rl.erb +172 -0
  50. data/ragel/lexer_common.rl.erb +46 -0
  51. data/spec/gherkin/c_lexer_spec.rb +21 -0
  52. data/spec/gherkin/fixtures/complex.feature +43 -0
  53. data/spec/gherkin/fixtures/i18n_fr.feature +13 -0
  54. data/spec/gherkin/fixtures/i18n_no.feature +6 -0
  55. data/spec/gherkin/fixtures/i18n_zh-CN.feature +8 -0
  56. data/spec/gherkin/fixtures/simple.feature +3 -0
  57. data/spec/gherkin/fixtures/simple_with_comments.feature +7 -0
  58. data/spec/gherkin/fixtures/simple_with_tags.feature +11 -0
  59. data/spec/gherkin/i18n_spec.rb +57 -0
  60. data/spec/gherkin/java_lexer_spec.rb +20 -0
  61. data/spec/gherkin/parser_spec.rb +28 -0
  62. data/spec/gherkin/rb_lexer_spec.rb +18 -0
  63. data/spec/gherkin/sexp_recorder.rb +29 -0
  64. data/spec/gherkin/shared/lexer_spec.rb +420 -0
  65. data/spec/gherkin/shared/py_string_spec.rb +112 -0
  66. data/spec/gherkin/shared/table_spec.rb +97 -0
  67. data/spec/gherkin/shared/tags_spec.rb +50 -0
  68. data/spec/spec_helper.rb +53 -0
  69. data/tasks/bench.rake +176 -0
  70. data/tasks/bench/feature_builder.rb +49 -0
  71. data/tasks/bench/generated/.gitignore +1 -0
  72. data/tasks/bench/null_listener.rb +4 -0
  73. data/tasks/cucumber.rake +20 -0
  74. data/tasks/ext.rake +49 -0
  75. data/tasks/ragel.rake +94 -0
  76. data/tasks/rdoc.rake +12 -0
  77. data/tasks/rspec.rake +15 -0
  78. metadata +204 -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,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,49 @@
1
+ CLEAN.include [
2
+ '**/*.{o,bundle,jar,so,obj,pdb,lib,def,exp,log}', 'ext/*/Makefile', 'ext/*/conftest.dSYM',
3
+ 'java/target'
4
+ ]
5
+
6
+ if(defined?(JRUBY_VERSION))
7
+
8
+ def ext_task(name)
9
+ desc "Compile the Native Java extensions"
10
+ task :compile => ['ragel:java'] do
11
+ sh("ant -f java/build.xml")
12
+ end
13
+ end
14
+
15
+ else # NOT JRUBY
16
+
17
+ def ext_task(name)
18
+ ext_dir = "ext/#{name}"
19
+ ext_bundle = "#{ext_dir}/#{name}.#{Config::CONFIG['DLEXT']}"
20
+ ext_files = FileList[
21
+ "#{ext_dir}/*.c",
22
+ "#{ext_dir}/*.h",
23
+ "#{ext_dir}/*.rl",
24
+ "#{ext_dir}/extconf.rb",
25
+ "#{ext_dir}/Makefile",
26
+ "lib"
27
+ ]
28
+
29
+ task "compile:#{name}" => ["#{ext_dir}/Makefile", ext_bundle]
30
+
31
+ desc "Compile the Native C extensions"
32
+ task :compile => ['ragel:c', "compile:#{name}"]
33
+
34
+ file "#{ext_dir}/Makefile" => ["#{ext_dir}/extconf.rb"] do
35
+ cd(ext_dir) { ruby "extconf.rb" }
36
+ end
37
+
38
+ file ext_bundle => ext_files do
39
+ cd ext_dir do
40
+ sh(WINDOWS ? 'nmake' : 'make')
41
+ end
42
+ cp ext_bundle, 'lib/'
43
+ end
44
+ end
45
+ end
46
+
47
+ ext_task :gherkin_lexer
48
+
49
+ task :package => :compile
@@ -0,0 +1,94 @@
1
+ CLEAN.include [
2
+ 'ragel/i18n/*.rl',
3
+ 'lib/gherkin/rb_lexer/*.rb',
4
+ 'ext/gherkin_lexer/*.c',
5
+ 'java/src/gherkin/lexer/*.java',
6
+ ]
7
+
8
+ class RagelCompiler
9
+ RL_OUTPUT_DIR = File.dirname(__FILE__) + "/../ragel/i18n"
10
+
11
+ def initialize(target)
12
+ require 'yaml'
13
+ require 'erb'
14
+
15
+ @target = target
16
+ @flag, @output_dir, @filename_proc = case
17
+ when @target == "rb" then ["-R", "lib/gherkin/rb_lexer", lambda{|name| name}]
18
+ when @target == "c" then ["-C", "ext/gherkin_lexer", lambda{|name| name}]
19
+ when @target == "java" then ["-J", "java/src/gherkin/lexer", lambda{|name| name.gsub(/[\s-]/, '').capitalize}]
20
+ end
21
+
22
+ @i18n_languages = YAML.load_file(File.dirname(__FILE__) + '/../lib/gherkin/i18n.yml')
23
+ @common_tmpl = ERB.new(IO.read(File.dirname(__FILE__) + '/../ragel/lexer_common.rl.erb'))
24
+ @actions_tmpl = ERB.new(IO.read(File.dirname(__FILE__) + "/../ragel/lexer.#{@target}.rl.erb"))
25
+ end
26
+
27
+ def compile_all
28
+ @i18n_languages.keys.each do |lang|
29
+ compile(lang)
30
+ end
31
+ end
32
+
33
+ def compile(i18n_language)
34
+ FileUtils.mkdir(RL_OUTPUT_DIR) unless File.exist?(RL_OUTPUT_DIR)
35
+
36
+ common_path = RL_OUTPUT_DIR + "/lexer_common.#{i18n_language}.rl"
37
+ actions_path = RL_OUTPUT_DIR + "/#{i18n_language}.#{@target}.rl"
38
+
39
+ generate_common(i18n_language, common_path)
40
+ generate_actions(i18n_language, actions_path)
41
+
42
+ sh "ragel #{@flag} #{actions_path} -o #{@output_dir}/#{@filename_proc.call(i18n_language)}.#{@target}"
43
+ end
44
+
45
+ def generate_common(i18n_language, path)
46
+ i18n = prep_keywords(@i18n_languages['en'].merge(@i18n_languages[i18n_language]))
47
+ common = @common_tmpl.result(binding)
48
+ write common, path
49
+ end
50
+
51
+ def generate_actions(i18n_language, path)
52
+ i18n_lexer_class_name = i18n_language.gsub(/[\s-]/, '').capitalize
53
+ impl = @actions_tmpl.result(binding)
54
+ write impl, path
55
+ end
56
+
57
+ def prep_keywords(i18n)
58
+ delimited_keywords = %w{feature background scenario scenario_outline examples}
59
+ bare_keywords = %w{given when then and but}
60
+ all_keywords = delimited_keywords + bare_keywords
61
+
62
+ all_keywords.each { |kw| i18n[kw] = i18n[kw].split("|") }
63
+ delimited_keywords.each { |kw| i18n[kw].map! { |v| v += ':'} }
64
+ bare_keywords.each { |kw| i18n[kw].map! { |v| (v + ' ').sub(/< $/,'')} }
65
+ all_keywords.each { |kw| i18n[kw] = '("' + i18n[kw].join('" | "') + '")' }
66
+ i18n
67
+ end
68
+
69
+ def write(content, filename)
70
+ File.open(filename, "wb") do |file|
71
+ file.write(content)
72
+ end
73
+ end
74
+ end
75
+
76
+ namespace :ragel do
77
+ desc "Generate i18n sources for C lexers (TODO: Do it for all)"
78
+ task :c do
79
+ RagelCompiler.new("c").compile('en')
80
+ end
81
+
82
+ desc "Generate all i18n Ruby lexers"
83
+ task :rb do
84
+ RagelCompiler.new("rb").compile_all
85
+ end
86
+
87
+ desc "Generate all i18n Java lexers"
88
+ task :java do
89
+ RagelCompiler.new("java").compile_all
90
+ end
91
+ end
92
+
93
+ desc "Generate all i18n lexers for all programming languages"
94
+ task :ragel => ['ragel:c', 'ragel:rb', 'ragel:java']
@@ -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,204 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: gherkin
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.3
5
+ platform: universal-java-1.5
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-11-25 00:00:00 +01:00
15
+ default_executable: gherkin
16
+ dependencies:
17
+ - !ruby/object:Gem::Dependency
18
+ name: rspec
19
+ type: :development
20
+ version_requirement:
21
+ version_requirements: !ruby/object:Gem::Requirement
22
+ requirements:
23
+ - - "="
24
+ - !ruby/object:Gem::Version
25
+ version: 1.2.9
26
+ version:
27
+ - !ruby/object:Gem::Dependency
28
+ name: cucumber
29
+ type: :development
30
+ version_requirement:
31
+ version_requirements: !ruby/object:Gem::Requirement
32
+ requirements:
33
+ - - ">="
34
+ - !ruby/object:Gem::Version
35
+ version: "0"
36
+ version:
37
+ description: A fast Gherkin lexer in Ragel
38
+ email: cukes@googlegroups.com
39
+ executables:
40
+ - gherkin
41
+ extensions: []
42
+
43
+ extra_rdoc_files:
44
+ - LICENSE
45
+ - README.rdoc
46
+ files:
47
+ - .gitignore
48
+ - LICENSE
49
+ - README.rdoc
50
+ - Rakefile
51
+ - VERSION.yml
52
+ - bin/gherkin
53
+ - cucumber.yml
54
+ - ext/gherkin_lexer/.gitignore
55
+ - ext/gherkin_lexer/extconf.rb
56
+ - features/feature_parser.feature
57
+ - features/native_lexer.feature
58
+ - features/parser_with_native_lexer.feature
59
+ - features/pretty_printer.feature
60
+ - features/step_definitions/gherkin_steps.rb
61
+ - features/step_definitions/pretty_printer_steps.rb
62
+ - features/steps_parser.feature
63
+ - features/support/env.rb
64
+ - gherkin.gemspec
65
+ - java/.gitignore
66
+ - java/Gherkin.iml
67
+ - java/build.xml
68
+ - java/src/gherkin/FixJava.java
69
+ - java/src/gherkin/Lexer.java
70
+ - java/src/gherkin/LexingError.java
71
+ - java/src/gherkin/Listener.java
72
+ - java/src/gherkin/ParseError.java
73
+ - java/src/gherkin/Parser.java
74
+ - java/src/gherkin/lexer/.gitignore
75
+ - java/src/gherkin/parser/StateMachineReader.java
76
+ - lib/.gitignore
77
+ - lib/gherkin.jar
78
+ - lib/gherkin.rb
79
+ - lib/gherkin/c_lexer.rb
80
+ - lib/gherkin/i18n.yml
81
+ - lib/gherkin/i18n_lexer.rb
82
+ - lib/gherkin/java_lexer.rb
83
+ - lib/gherkin/lexer.rb
84
+ - lib/gherkin/parser.rb
85
+ - lib/gherkin/parser/meta.txt
86
+ - lib/gherkin/parser/root.txt
87
+ - lib/gherkin/parser/steps.txt
88
+ - lib/gherkin/rb_lexer.rb
89
+ - lib/gherkin/rb_lexer/.gitignore
90
+ - lib/gherkin/rb_lexer/README.rdoc
91
+ - lib/gherkin/rb_lexer/ar.rb
92
+ - lib/gherkin/rb_lexer/bg.rb
93
+ - lib/gherkin/rb_lexer/cat.rb
94
+ - lib/gherkin/rb_lexer/cs.rb
95
+ - lib/gherkin/rb_lexer/cy.rb
96
+ - lib/gherkin/rb_lexer/da.rb
97
+ - lib/gherkin/rb_lexer/de.rb
98
+ - lib/gherkin/rb_lexer/en-au.rb
99
+ - lib/gherkin/rb_lexer/en-lol.rb
100
+ - lib/gherkin/rb_lexer/en-tx.rb
101
+ - lib/gherkin/rb_lexer/en.rb
102
+ - lib/gherkin/rb_lexer/es.rb
103
+ - lib/gherkin/rb_lexer/et.rb
104
+ - lib/gherkin/rb_lexer/fi.rb
105
+ - lib/gherkin/rb_lexer/fr.rb
106
+ - lib/gherkin/rb_lexer/he.rb
107
+ - lib/gherkin/rb_lexer/hr.rb
108
+ - lib/gherkin/rb_lexer/hu.rb
109
+ - lib/gherkin/rb_lexer/id.rb
110
+ - lib/gherkin/rb_lexer/it.rb
111
+ - lib/gherkin/rb_lexer/ja.rb
112
+ - lib/gherkin/rb_lexer/ko.rb
113
+ - lib/gherkin/rb_lexer/lt.rb
114
+ - lib/gherkin/rb_lexer/lv.rb
115
+ - lib/gherkin/rb_lexer/nl.rb
116
+ - lib/gherkin/rb_lexer/no.rb
117
+ - lib/gherkin/rb_lexer/pl.rb
118
+ - lib/gherkin/rb_lexer/pt.rb
119
+ - lib/gherkin/rb_lexer/ro.rb
120
+ - lib/gherkin/rb_lexer/ro2.rb
121
+ - lib/gherkin/rb_lexer/ru.rb
122
+ - lib/gherkin/rb_lexer/se.rb
123
+ - lib/gherkin/rb_lexer/sk.rb
124
+ - lib/gherkin/rb_lexer/sr-Latn.rb
125
+ - lib/gherkin/rb_lexer/sr.rb
126
+ - lib/gherkin/rb_lexer/tr.rb
127
+ - lib/gherkin/rb_lexer/uz.rb
128
+ - lib/gherkin/rb_lexer/vi.rb
129
+ - lib/gherkin/rb_lexer/zh-CN.rb
130
+ - lib/gherkin/rb_lexer/zh-TW.rb
131
+ - lib/gherkin/rb_parser.rb
132
+ - lib/gherkin/tools/pretty_printer.rb
133
+ - ragel/i18n/.gitignore
134
+ - ragel/lexer.c.rl.erb
135
+ - ragel/lexer.java.rl.erb
136
+ - ragel/lexer.rb.rl.erb
137
+ - ragel/lexer_common.rl.erb
138
+ - spec/gherkin/c_lexer_spec.rb
139
+ - spec/gherkin/fixtures/complex.feature
140
+ - spec/gherkin/fixtures/i18n_fr.feature
141
+ - spec/gherkin/fixtures/i18n_no.feature
142
+ - spec/gherkin/fixtures/i18n_zh-CN.feature
143
+ - spec/gherkin/fixtures/simple.feature
144
+ - spec/gherkin/fixtures/simple_with_comments.feature
145
+ - spec/gherkin/fixtures/simple_with_tags.feature
146
+ - spec/gherkin/i18n_spec.rb
147
+ - spec/gherkin/java_lexer_spec.rb
148
+ - spec/gherkin/parser_spec.rb
149
+ - spec/gherkin/rb_lexer_spec.rb
150
+ - spec/gherkin/sexp_recorder.rb
151
+ - spec/gherkin/shared/lexer_spec.rb
152
+ - spec/gherkin/shared/py_string_spec.rb
153
+ - spec/gherkin/shared/table_spec.rb
154
+ - spec/gherkin/shared/tags_spec.rb
155
+ - spec/spec_helper.rb
156
+ - tasks/bench.rake
157
+ - tasks/bench/feature_builder.rb
158
+ - tasks/bench/generated/.gitignore
159
+ - tasks/bench/null_listener.rb
160
+ - tasks/cucumber.rake
161
+ - tasks/ext.rake
162
+ - tasks/ragel.rake
163
+ - tasks/rdoc.rake
164
+ - tasks/rspec.rake
165
+ has_rdoc: true
166
+ homepage: http://github.com/aslakhellesoy/gherkin
167
+ licenses: []
168
+
169
+ post_install_message:
170
+ rdoc_options:
171
+ - --charset=UTF-8
172
+ require_paths:
173
+ - lib
174
+ required_ruby_version: !ruby/object:Gem::Requirement
175
+ requirements:
176
+ - - ">="
177
+ - !ruby/object:Gem::Version
178
+ version: "0"
179
+ version:
180
+ required_rubygems_version: !ruby/object:Gem::Requirement
181
+ requirements:
182
+ - - ">="
183
+ - !ruby/object:Gem::Version
184
+ version: "0"
185
+ version:
186
+ requirements: []
187
+
188
+ rubyforge_project:
189
+ rubygems_version: 1.3.5
190
+ signing_key:
191
+ specification_version: 3
192
+ summary: Fast Gherkin lexer
193
+ test_files:
194
+ - spec/spec_helper.rb
195
+ - spec/gherkin/c_lexer_spec.rb
196
+ - spec/gherkin/i18n_spec.rb
197
+ - spec/gherkin/java_lexer_spec.rb
198
+ - spec/gherkin/parser_spec.rb
199
+ - spec/gherkin/rb_lexer_spec.rb
200
+ - spec/gherkin/sexp_recorder.rb
201
+ - spec/gherkin/shared/lexer_spec.rb
202
+ - spec/gherkin/shared/py_string_spec.rb
203
+ - spec/gherkin/shared/table_spec.rb
204
+ - spec/gherkin/shared/tags_spec.rb