gherkin 0.0.4-i386-mswin32

Sign up to get free protection for your applications and to get access to all the features.
Files changed (79) hide show
  1. data/.gitignore +7 -0
  2. data/LICENSE +20 -0
  3. data/README.rdoc +66 -0
  4. data/Rakefile +49 -0
  5. data/VERSION.yml +4 -0
  6. data/bin/gherkin +10 -0
  7. data/cucumber.yml +3 -0
  8. data/features/feature_parser.feature +206 -0
  9. data/features/native_lexer.feature +19 -0
  10. data/features/parser_with_native_lexer.feature +205 -0
  11. data/features/pretty_printer.feature +14 -0
  12. data/features/step_definitions/gherkin_steps.rb +34 -0
  13. data/features/step_definitions/pretty_printer_steps.rb +56 -0
  14. data/features/steps_parser.feature +46 -0
  15. data/features/support/env.rb +33 -0
  16. data/gherkin.gemspec +180 -0
  17. data/java/.gitignore +2 -0
  18. data/java/Gherkin.iml +24 -0
  19. data/java/build.xml +13 -0
  20. data/java/src/gherkin/FixJava.java +34 -0
  21. data/java/src/gherkin/Lexer.java +5 -0
  22. data/java/src/gherkin/LexingError.java +7 -0
  23. data/java/src/gherkin/Listener.java +27 -0
  24. data/java/src/gherkin/ParseError.java +22 -0
  25. data/java/src/gherkin/Parser.java +185 -0
  26. data/java/src/gherkin/lexer/.gitignore +1 -0
  27. data/java/src/gherkin/parser/StateMachineReader.java +62 -0
  28. data/lib/.gitignore +4 -0
  29. data/lib/gherkin.rb +2 -0
  30. data/lib/gherkin/c_lexer.rb +10 -0
  31. data/lib/gherkin/core_ext/array.rb +5 -0
  32. data/lib/gherkin/i18n.yml +535 -0
  33. data/lib/gherkin/i18n_lexer.rb +29 -0
  34. data/lib/gherkin/java_lexer.rb +10 -0
  35. data/lib/gherkin/lexer.rb +43 -0
  36. data/lib/gherkin/parser.rb +19 -0
  37. data/lib/gherkin/parser/meta.txt +4 -0
  38. data/lib/gherkin/parser/root.txt +9 -0
  39. data/lib/gherkin/parser/steps.txt +3 -0
  40. data/lib/gherkin/rb_lexer.rb +10 -0
  41. data/lib/gherkin/rb_lexer/.gitignore +1 -0
  42. data/lib/gherkin/rb_lexer/README.rdoc +8 -0
  43. data/lib/gherkin/rb_parser.rb +117 -0
  44. data/lib/gherkin/tools/pretty_printer.rb +83 -0
  45. data/nativegems.sh +5 -0
  46. data/ragel/i18n/.gitignore +1 -0
  47. data/ragel/lexer.c.rl.erb +401 -0
  48. data/ragel/lexer.java.rl.erb +200 -0
  49. data/ragel/lexer.rb.rl.erb +171 -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/1.feature +8 -0
  53. data/spec/gherkin/fixtures/complex.feature +43 -0
  54. data/spec/gherkin/fixtures/i18n_fr.feature +13 -0
  55. data/spec/gherkin/fixtures/i18n_no.feature +6 -0
  56. data/spec/gherkin/fixtures/i18n_zh-CN.feature +8 -0
  57. data/spec/gherkin/fixtures/simple.feature +3 -0
  58. data/spec/gherkin/fixtures/simple_with_comments.feature +7 -0
  59. data/spec/gherkin/fixtures/simple_with_tags.feature +11 -0
  60. data/spec/gherkin/i18n_spec.rb +57 -0
  61. data/spec/gherkin/java_lexer_spec.rb +20 -0
  62. data/spec/gherkin/parser_spec.rb +28 -0
  63. data/spec/gherkin/rb_lexer_spec.rb +18 -0
  64. data/spec/gherkin/sexp_recorder.rb +29 -0
  65. data/spec/gherkin/shared/lexer_spec.rb +433 -0
  66. data/spec/gherkin/shared/py_string_spec.rb +124 -0
  67. data/spec/gherkin/shared/table_spec.rb +97 -0
  68. data/spec/gherkin/shared/tags_spec.rb +50 -0
  69. data/spec/spec_helper.rb +53 -0
  70. data/tasks/bench.rake +193 -0
  71. data/tasks/bench/feature_builder.rb +49 -0
  72. data/tasks/bench/generated/.gitignore +1 -0
  73. data/tasks/bench/null_listener.rb +4 -0
  74. data/tasks/compile.rake +70 -0
  75. data/tasks/cucumber.rake +20 -0
  76. data/tasks/ragel_task.rb +83 -0
  77. data/tasks/rdoc.rake +12 -0
  78. data/tasks/rspec.rake +15 -0
  79. metadata +214 -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
+
3
+ CLEAN.include [
4
+ '**/*.{o,bundle,jar,so,obj,pdb,lib,def,exp,log}', 'ext',
5
+ 'java/target',
6
+ 'ragel/i18n/*.rl',
7
+ 'lib/gherkin/rb_lexer/*.rb',
8
+ 'ext/**/*.c',
9
+ 'java/src/gherkin/lexer/*.java'
10
+ ]
11
+
12
+ desc "Compile the Java extensions"
13
+ task :jar do
14
+ sh("ant -f java/build.xml")
15
+ end
16
+
17
+ YAML.load_file(File.dirname(__FILE__) + '/../lib/gherkin/i18n.yml').each do |i18n, keywords|
18
+ i18n = i18n.gsub(/[\s-]/, '')
19
+
20
+ java = RagelTask.new('java', i18n, keywords)
21
+ rb = RagelTask.new('rb', i18n, keywords)
22
+
23
+ task :jar => java.target
24
+ task :jar => rb.target
25
+
26
+ begin
27
+ require 'rake/extensiontask'
28
+ c = RagelTask.new('c', i18n, keywords)
29
+
30
+ extconf = "ext/gherkin_lexer_#{i18n}/extconf.rb"
31
+
32
+ file extconf do
33
+ FileUtils.mkdir(File.dirname(extconf)) unless File.directory?(File.dirname(extconf))
34
+ File.open(extconf, "w") do |io|
35
+ io.write(<<-EOF)
36
+ require 'mkmf'
37
+ dir_config("gherkin_lexer_#{i18n}")
38
+ have_library("c", "main")
39
+ create_makefile("gherkin_lexer_#{i18n}")
40
+ EOF
41
+ end
42
+ end
43
+
44
+ Rake::ExtensionTask.new("gherkin_lexer_#{i18n}") do |ext|
45
+ if ENV['RUBY_CC_VERSION']
46
+ ext.cross_compile = true
47
+ ext.cross_platform = 'i386-mingw32'
48
+ end
49
+ end
50
+
51
+ task :compile => c.target
52
+ task :compile => rb.target
53
+
54
+ # The way tasks are defined with compile:xxx (but without namespace) in rake-compiler forces us
55
+ # to use these hacks for setting up dependencies. Ugly!
56
+ Rake::Task["compile:gherkin_lexer_#{i18n}"].prerequisites.unshift(extconf)
57
+ Rake::Task["compile:gherkin_lexer_#{i18n}"].prerequisites.unshift(c.target)
58
+ Rake::Task["compile:gherkin_lexer_#{i18n}"].prerequisites.unshift(rb.target)
59
+
60
+ Rake::Task["compile"].prerequisites.unshift(extconf)
61
+ Rake::Task["compile"].prerequisites.unshift(c.target)
62
+ Rake::Task["compile"].prerequisites.unshift(rb.target)
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,83 @@
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, keywords)
8
+ @lang = lang
9
+ @i18n = i18n
10
+ @keywords = keywords
11
+ define_tasks
12
+ end
13
+
14
+ def define_tasks
15
+ file target => [lang_ragel, common_ragel] do
16
+ mkdir_p(File.dirname(target)) unless File.directory?(File.dirname(target))
17
+ sh "ragel #{flags} #{lang_ragel} -o #{target}"
18
+ end
19
+
20
+ file lang_ragel => lang_erb do
21
+ impl = ERB.new(IO.read(lang_erb)).result(binding)
22
+ write(impl, lang_ragel)
23
+ end
24
+
25
+ file common_ragel => common_erb do
26
+ keywords = prep_keywords
27
+ common = ERB.new(IO.read(common_erb)).result(binding)
28
+ write(common, common_ragel)
29
+ end
30
+ end
31
+
32
+ def target
33
+ {
34
+ 'c' => "ext/gherkin_lexer_#{@i18n}/gherkin_lexer_#{@i18n}.c",
35
+ 'java' => "java/src/gherkin/lexer/#{@i18n.capitalize}.java",
36
+ 'rb' => "lib/gherkin/rb_lexer/#{@i18n}.rb"
37
+ }[@lang]
38
+ end
39
+
40
+ def common_ragel
41
+ RL_OUTPUT_DIR + "/lexer_common.#{@i18n}.rl"
42
+ end
43
+
44
+ def common_erb
45
+ File.dirname(__FILE__) + '/../ragel/lexer_common.rl.erb'
46
+ end
47
+
48
+ def lang_ragel
49
+ RL_OUTPUT_DIR + "/#{@i18n}.#{@lang}.rl"
50
+ end
51
+
52
+ def lang_erb
53
+ File.dirname(__FILE__) + "/../ragel/lexer.#{@lang}.rl.erb"
54
+ end
55
+
56
+ def flags
57
+ {
58
+ 'c' => '-C',
59
+ 'java' => '-J',
60
+ 'rb' => '-R'
61
+ }[@lang]
62
+ end
63
+
64
+ def prep_keywords
65
+ keywords = @keywords.dup
66
+ delimited_keywords = %w{feature background scenario scenario_outline examples}
67
+ bare_keywords = %w{given when then and but}
68
+ all_keywords = delimited_keywords + bare_keywords
69
+
70
+ all_keywords.each { |k| keywords[k] = keywords[k].split("|") }
71
+ delimited_keywords.each { |k| keywords[k].map! { |v| v += ':'} }
72
+ bare_keywords.each { |k| keywords[k].map! { |v| (v + ' ').sub(/< $/, '')} }
73
+ all_keywords.each { |k| keywords[k] = '("' + keywords[k].join('" | "') + '")' }
74
+ keywords
75
+ end
76
+
77
+ def write(content, filename)
78
+ mkdir_p(File.dirname(filename)) unless File.directory?(File.dirname(filename))
79
+ File.open(filename, "wb") do |file|
80
+ file.write(content)
81
+ end
82
+ end
83
+ 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,214 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: gherkin
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.4
5
+ platform: i386-mswin32
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-28 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.4.4
36
+ version:
37
+ - !ruby/object:Gem::Dependency
38
+ name: rake-compiler
39
+ type: :development
40
+ version_requirement:
41
+ version_requirements: !ruby/object:Gem::Requirement
42
+ requirements:
43
+ - - "="
44
+ - !ruby/object:Gem::Version
45
+ version: 0.6.0
46
+ version:
47
+ description: A fast Gherkin lexer in Ragel
48
+ email: cukes@googlegroups.com
49
+ executables:
50
+ - gherkin
51
+ extensions: []
52
+
53
+ extra_rdoc_files:
54
+ - LICENSE
55
+ - README.rdoc
56
+ files:
57
+ - .gitignore
58
+ - LICENSE
59
+ - README.rdoc
60
+ - Rakefile
61
+ - VERSION.yml
62
+ - bin/gherkin
63
+ - cucumber.yml
64
+ - features/feature_parser.feature
65
+ - features/native_lexer.feature
66
+ - features/parser_with_native_lexer.feature
67
+ - features/pretty_printer.feature
68
+ - features/step_definitions/gherkin_steps.rb
69
+ - features/step_definitions/pretty_printer_steps.rb
70
+ - features/steps_parser.feature
71
+ - features/support/env.rb
72
+ - gherkin.gemspec
73
+ - java/.gitignore
74
+ - java/Gherkin.iml
75
+ - java/build.xml
76
+ - java/src/gherkin/FixJava.java
77
+ - java/src/gherkin/Lexer.java
78
+ - java/src/gherkin/LexingError.java
79
+ - java/src/gherkin/Listener.java
80
+ - java/src/gherkin/ParseError.java
81
+ - java/src/gherkin/Parser.java
82
+ - java/src/gherkin/lexer/.gitignore
83
+ - java/src/gherkin/parser/StateMachineReader.java
84
+ - lib/.gitignore
85
+ - lib/gherkin.rb
86
+ - lib/gherkin/c_lexer.rb
87
+ - lib/gherkin/core_ext/array.rb
88
+ - lib/gherkin/i18n.yml
89
+ - lib/gherkin/i18n_lexer.rb
90
+ - lib/gherkin/java_lexer.rb
91
+ - lib/gherkin/lexer.rb
92
+ - lib/gherkin/parser.rb
93
+ - lib/gherkin/parser/meta.txt
94
+ - lib/gherkin/parser/root.txt
95
+ - lib/gherkin/parser/steps.txt
96
+ - lib/gherkin/rb_lexer.rb
97
+ - lib/gherkin/rb_lexer/.gitignore
98
+ - lib/gherkin/rb_lexer/README.rdoc
99
+ - lib/gherkin/rb_parser.rb
100
+ - lib/gherkin/tools/pretty_printer.rb
101
+ - lib/gherkin_lexer_ar.so
102
+ - lib/gherkin_lexer_bg.so
103
+ - lib/gherkin_lexer_cat.so
104
+ - lib/gherkin_lexer_cs.so
105
+ - lib/gherkin_lexer_cy.so
106
+ - lib/gherkin_lexer_da.so
107
+ - lib/gherkin_lexer_de.so
108
+ - lib/gherkin_lexer_en.so
109
+ - lib/gherkin_lexer_enau.so
110
+ - lib/gherkin_lexer_enlol.so
111
+ - lib/gherkin_lexer_entx.so
112
+ - lib/gherkin_lexer_es.so
113
+ - lib/gherkin_lexer_et.so
114
+ - lib/gherkin_lexer_fi.so
115
+ - lib/gherkin_lexer_fr.so
116
+ - lib/gherkin_lexer_he.so
117
+ - lib/gherkin_lexer_hr.so
118
+ - lib/gherkin_lexer_hu.so
119
+ - lib/gherkin_lexer_id.so
120
+ - lib/gherkin_lexer_it.so
121
+ - lib/gherkin_lexer_ja.so
122
+ - lib/gherkin_lexer_ko.so
123
+ - lib/gherkin_lexer_lt.so
124
+ - lib/gherkin_lexer_lv.so
125
+ - lib/gherkin_lexer_nl.so
126
+ - lib/gherkin_lexer_no.so
127
+ - lib/gherkin_lexer_pl.so
128
+ - lib/gherkin_lexer_pt.so
129
+ - lib/gherkin_lexer_ro.so
130
+ - lib/gherkin_lexer_ro2.so
131
+ - lib/gherkin_lexer_ru.so
132
+ - lib/gherkin_lexer_se.so
133
+ - lib/gherkin_lexer_sk.so
134
+ - lib/gherkin_lexer_sr.so
135
+ - lib/gherkin_lexer_srLatn.so
136
+ - lib/gherkin_lexer_tr.so
137
+ - lib/gherkin_lexer_uz.so
138
+ - lib/gherkin_lexer_vi.so
139
+ - lib/gherkin_lexer_zhCN.so
140
+ - lib/gherkin_lexer_zhTW.so
141
+ - nativegems.sh
142
+ - ragel/i18n/.gitignore
143
+ - ragel/lexer.c.rl.erb
144
+ - ragel/lexer.java.rl.erb
145
+ - ragel/lexer.rb.rl.erb
146
+ - ragel/lexer_common.rl.erb
147
+ - spec/gherkin/c_lexer_spec.rb
148
+ - spec/gherkin/fixtures/1.feature
149
+ - spec/gherkin/fixtures/complex.feature
150
+ - spec/gherkin/fixtures/i18n_fr.feature
151
+ - spec/gherkin/fixtures/i18n_no.feature
152
+ - spec/gherkin/fixtures/i18n_zh-CN.feature
153
+ - spec/gherkin/fixtures/simple.feature
154
+ - spec/gherkin/fixtures/simple_with_comments.feature
155
+ - spec/gherkin/fixtures/simple_with_tags.feature
156
+ - spec/gherkin/i18n_spec.rb
157
+ - spec/gherkin/java_lexer_spec.rb
158
+ - spec/gherkin/parser_spec.rb
159
+ - spec/gherkin/rb_lexer_spec.rb
160
+ - spec/gherkin/sexp_recorder.rb
161
+ - spec/gherkin/shared/lexer_spec.rb
162
+ - spec/gherkin/shared/py_string_spec.rb
163
+ - spec/gherkin/shared/table_spec.rb
164
+ - spec/gherkin/shared/tags_spec.rb
165
+ - spec/spec_helper.rb
166
+ - tasks/bench.rake
167
+ - tasks/bench/feature_builder.rb
168
+ - tasks/bench/generated/.gitignore
169
+ - tasks/bench/null_listener.rb
170
+ - tasks/compile.rake
171
+ - tasks/cucumber.rake
172
+ - tasks/ragel_task.rb
173
+ - tasks/rdoc.rake
174
+ - tasks/rspec.rake
175
+ has_rdoc: true
176
+ homepage: http://github.com/aslakhellesoy/gherkin
177
+ licenses: []
178
+
179
+ post_install_message:
180
+ rdoc_options:
181
+ - --charset=UTF-8
182
+ require_paths:
183
+ - lib
184
+ required_ruby_version: !ruby/object:Gem::Requirement
185
+ requirements:
186
+ - - ">="
187
+ - !ruby/object:Gem::Version
188
+ version: "0"
189
+ version:
190
+ required_rubygems_version: !ruby/object:Gem::Requirement
191
+ requirements:
192
+ - - ">="
193
+ - !ruby/object:Gem::Version
194
+ version: "0"
195
+ version:
196
+ requirements: []
197
+
198
+ rubyforge_project:
199
+ rubygems_version: 1.3.5
200
+ signing_key:
201
+ specification_version: 3
202
+ summary: Fast Gherkin lexer
203
+ test_files:
204
+ - spec/gherkin/c_lexer_spec.rb
205
+ - spec/gherkin/i18n_spec.rb
206
+ - spec/gherkin/java_lexer_spec.rb
207
+ - spec/gherkin/parser_spec.rb
208
+ - spec/gherkin/rb_lexer_spec.rb
209
+ - spec/gherkin/sexp_recorder.rb
210
+ - spec/gherkin/shared/lexer_spec.rb
211
+ - spec/gherkin/shared/py_string_spec.rb
212
+ - spec/gherkin/shared/table_spec.rb
213
+ - spec/gherkin/shared/tags_spec.rb
214
+ - spec/spec_helper.rb