gherkin 0.0.4 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -19,8 +19,10 @@ rake clobber
19
19
 
20
20
  == Release process
21
21
 
22
- Run just "rake" for each platform (1.8.6, 1.8.7, 1.9, jruby) to make sure all is green.
22
+ Run just "rake clean spec cucumber" for each platform (1.8.6, 1.8.7, 1.9, jruby) to make sure all is green.
23
+ Make sure jruby was run last, so the jar file is left intact.
23
24
 
25
+ 0) rvm 1.8.7
24
26
  1) Bump version in the VERSION file
25
27
  2) rake gemspec
26
28
  3) Commit everything
data/Rakefile CHANGED
@@ -46,4 +46,6 @@ end
46
46
 
47
47
  Dir['tasks/**/*.rake'].each { |rake| load rake }
48
48
 
49
- task :default => [:jar, :compile, :spec, :cucumber]
49
+ task :default => [:spec, :cucumber]
50
+ task :spec => defined?(JRUBY_VERSION) ? :jar : :compile
51
+ task :cucumber => defined?(JRUBY_VERSION) ? :jar : :compile
@@ -1,4 +1,4 @@
1
1
  ---
2
2
  :minor: 0
3
- :patch: 4
4
- :major: 0
3
+ :patch: 0
4
+ :major: 1
@@ -5,16 +5,15 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{gherkin}
8
- s.version = "0.0.4"
8
+ s.version = "1.0.0"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Mike Sassak", "Gregory Hnatiuk", "Aslak Helles\303\270y"]
12
- s.date = %q{2009-11-28}
12
+ s.date = %q{2009-12-01}
13
13
  s.default_executable = %q{gherkin}
14
14
  s.description = %q{A fast Gherkin lexer in Ragel}
15
15
  s.email = %q{cukes@googlegroups.com}
16
16
  s.executables = ["gherkin"]
17
- s.extensions = ["ext/gherkin_lexer_ar/extconf.rb", "ext/gherkin_lexer_bg/extconf.rb", "ext/gherkin_lexer_cat/extconf.rb", "ext/gherkin_lexer_cs/extconf.rb", "ext/gherkin_lexer_cy/extconf.rb", "ext/gherkin_lexer_da/extconf.rb", "ext/gherkin_lexer_de/extconf.rb", "ext/gherkin_lexer_en/extconf.rb", "ext/gherkin_lexer_enau/extconf.rb", "ext/gherkin_lexer_enlol/extconf.rb", "ext/gherkin_lexer_entx/extconf.rb", "ext/gherkin_lexer_es/extconf.rb", "ext/gherkin_lexer_et/extconf.rb", "ext/gherkin_lexer_fi/extconf.rb", "ext/gherkin_lexer_fr/extconf.rb", "ext/gherkin_lexer_he/extconf.rb", "ext/gherkin_lexer_hr/extconf.rb", "ext/gherkin_lexer_hu/extconf.rb", "ext/gherkin_lexer_id/extconf.rb", "ext/gherkin_lexer_it/extconf.rb", "ext/gherkin_lexer_ja/extconf.rb", "ext/gherkin_lexer_ko/extconf.rb", "ext/gherkin_lexer_lt/extconf.rb", "ext/gherkin_lexer_lv/extconf.rb", "ext/gherkin_lexer_nl/extconf.rb", "ext/gherkin_lexer_no/extconf.rb", "ext/gherkin_lexer_pl/extconf.rb", "ext/gherkin_lexer_pt/extconf.rb", "ext/gherkin_lexer_ro/extconf.rb", "ext/gherkin_lexer_ro2/extconf.rb", "ext/gherkin_lexer_ru/extconf.rb", "ext/gherkin_lexer_se/extconf.rb", "ext/gherkin_lexer_sk/extconf.rb", "ext/gherkin_lexer_sr/extconf.rb", "ext/gherkin_lexer_srLatn/extconf.rb", "ext/gherkin_lexer_tr/extconf.rb", "ext/gherkin_lexer_uz/extconf.rb", "ext/gherkin_lexer_vi/extconf.rb", "ext/gherkin_lexer_zhCN/extconf.rb", "ext/gherkin_lexer_zhTW/extconf.rb"]
18
17
  s.extra_rdoc_files = [
19
18
  "LICENSE",
20
19
  "README.rdoc"
@@ -27,46 +26,6 @@ Gem::Specification.new do |s|
27
26
  "VERSION.yml",
28
27
  "bin/gherkin",
29
28
  "cucumber.yml",
30
- "ext/gherkin_lexer_ar/gherkin_lexer_ar.c",
31
- "ext/gherkin_lexer_bg/gherkin_lexer_bg.c",
32
- "ext/gherkin_lexer_cat/gherkin_lexer_cat.c",
33
- "ext/gherkin_lexer_cs/gherkin_lexer_cs.c",
34
- "ext/gherkin_lexer_cy/gherkin_lexer_cy.c",
35
- "ext/gherkin_lexer_da/gherkin_lexer_da.c",
36
- "ext/gherkin_lexer_de/gherkin_lexer_de.c",
37
- "ext/gherkin_lexer_en/gherkin_lexer_en.c",
38
- "ext/gherkin_lexer_enau/gherkin_lexer_enau.c",
39
- "ext/gherkin_lexer_enlol/gherkin_lexer_enlol.c",
40
- "ext/gherkin_lexer_entx/gherkin_lexer_entx.c",
41
- "ext/gherkin_lexer_es/gherkin_lexer_es.c",
42
- "ext/gherkin_lexer_et/gherkin_lexer_et.c",
43
- "ext/gherkin_lexer_fi/gherkin_lexer_fi.c",
44
- "ext/gherkin_lexer_fr/gherkin_lexer_fr.c",
45
- "ext/gherkin_lexer_he/gherkin_lexer_he.c",
46
- "ext/gherkin_lexer_hr/gherkin_lexer_hr.c",
47
- "ext/gherkin_lexer_hu/gherkin_lexer_hu.c",
48
- "ext/gherkin_lexer_id/gherkin_lexer_id.c",
49
- "ext/gherkin_lexer_it/gherkin_lexer_it.c",
50
- "ext/gherkin_lexer_ja/gherkin_lexer_ja.c",
51
- "ext/gherkin_lexer_ko/gherkin_lexer_ko.c",
52
- "ext/gherkin_lexer_lt/gherkin_lexer_lt.c",
53
- "ext/gherkin_lexer_lv/gherkin_lexer_lv.c",
54
- "ext/gherkin_lexer_nl/gherkin_lexer_nl.c",
55
- "ext/gherkin_lexer_no/gherkin_lexer_no.c",
56
- "ext/gherkin_lexer_pl/gherkin_lexer_pl.c",
57
- "ext/gherkin_lexer_pt/gherkin_lexer_pt.c",
58
- "ext/gherkin_lexer_ro/gherkin_lexer_ro.c",
59
- "ext/gherkin_lexer_ro2/gherkin_lexer_ro2.c",
60
- "ext/gherkin_lexer_ru/gherkin_lexer_ru.c",
61
- "ext/gherkin_lexer_se/gherkin_lexer_se.c",
62
- "ext/gherkin_lexer_sk/gherkin_lexer_sk.c",
63
- "ext/gherkin_lexer_sr/gherkin_lexer_sr.c",
64
- "ext/gherkin_lexer_srLatn/gherkin_lexer_srLatn.c",
65
- "ext/gherkin_lexer_tr/gherkin_lexer_tr.c",
66
- "ext/gherkin_lexer_uz/gherkin_lexer_uz.c",
67
- "ext/gherkin_lexer_vi/gherkin_lexer_vi.c",
68
- "ext/gherkin_lexer_zhCN/gherkin_lexer_zhCN.c",
69
- "ext/gherkin_lexer_zhTW/gherkin_lexer_zhTW.c",
70
29
  "features/feature_parser.feature",
71
30
  "features/native_lexer.feature",
72
31
  "features/parser_with_native_lexer.feature",
@@ -91,6 +50,7 @@ Gem::Specification.new do |s|
91
50
  "lib/gherkin.rb",
92
51
  "lib/gherkin/c_lexer.rb",
93
52
  "lib/gherkin/core_ext/array.rb",
53
+ "lib/gherkin/i18n.rb",
94
54
  "lib/gherkin/i18n.yml",
95
55
  "lib/gherkin/i18n_lexer.rb",
96
56
  "lib/gherkin/java_lexer.rb",
@@ -0,0 +1,80 @@
1
+ module Gherkin
2
+ class I18n
3
+ KEYWORD_KEYS = %w{name native feature background scenario scenario_outline examples given when then and but}
4
+ LANGUAGES = YAML.load_file(File.dirname(__FILE__) + '/i18n.yml')
5
+
6
+ class << self
7
+ # Used by code generators for other lexer tools like pygments lexer and textmate bundle
8
+ def all
9
+ LANGUAGES.keys.sort.map{|key| get(key)}
10
+ end
11
+
12
+ def get(key)
13
+ languages[key] ||= new(key)
14
+ end
15
+
16
+ def languages
17
+ @languages ||= {}
18
+ end
19
+ end
20
+
21
+ def initialize(key)
22
+ @key = key
23
+ @keywords = LANGUAGES[key]
24
+ raise "Language not supported: #{key.inspect}" if @key.nil?
25
+ @keywords['grammar_name'] = @keywords['name'].gsub(/\s/, '')
26
+ @parser = nil
27
+ end
28
+
29
+ def sanitized_key
30
+ @key.gsub(/[\s-]/, '')
31
+ end
32
+
33
+ def incomplete?
34
+ KEYWORD_KEYS.detect{|key| @keywords[key].nil?}
35
+ end
36
+
37
+ def feature_keywords
38
+ keywords('feature')
39
+ end
40
+
41
+ def scenario_keywords
42
+ keywords('scenario')
43
+ end
44
+
45
+ def scenario_outline_keywords
46
+ keywords('scenario_outline')
47
+ end
48
+
49
+ def background_keywords
50
+ keywords('background')
51
+ end
52
+
53
+ def examples_keywords
54
+ keywords('examples')
55
+ end
56
+
57
+ def but_keywords(space=true)
58
+ keywords('but', space)
59
+ end
60
+
61
+ def and_keywords(space=true)
62
+ keywords('and', space)
63
+ end
64
+
65
+ def step_keywords
66
+ %w{given when then and but}.map{|key| keywords(key, true)}.flatten.uniq
67
+ end
68
+
69
+ def keywords(key, space=false)
70
+ raise "No #{key} in #{@keywords.inspect}" if @keywords[key].nil?
71
+ @keywords[key].split('|').map{|kw| space ? keyword_space(kw) : kw}
72
+ end
73
+
74
+ private
75
+
76
+ def keyword_space(val)
77
+ (val + ' ').sub(/< $/,'')
78
+ end
79
+ end
80
+ end
@@ -7,6 +7,8 @@
7
7
 
8
8
  #ifdef HAVE_RUBY_RE_H
9
9
  #include <ruby/re.h>
10
+ #else
11
+ #include <re.h>
10
12
  #endif
11
13
 
12
14
  #ifdef HAVE_RUBY_ENCODING_H
@@ -232,7 +234,7 @@ static VALUE rb_eGherkinLexerError;
232
234
  }
233
235
  }
234
236
 
235
- include lexer_common "lexer_common.<%= @i18n %>.rl";
237
+ include lexer_common "lexer_common.<%= @i18n.sanitized_key %>.rl";
236
238
 
237
239
  }%%
238
240
 
@@ -350,7 +352,7 @@ static VALUE CLexer_scan(VALUE self, VALUE input)
350
352
  rb_str_append(input_copy, rb_str_new2("\n%_FEATURE_END_%"));
351
353
  char *data = RSTRING_PTR(input_copy);
352
354
  long len = RSTRING_LEN(input_copy);
353
-
355
+
354
356
  if (len == 0) {
355
357
  rb_raise(rb_eGherkinLexerError, "No content to lex.");
356
358
  } else {
@@ -387,14 +389,14 @@ static VALUE CLexer_scan(VALUE self, VALUE input)
387
389
  }
388
390
  }
389
391
 
390
- void Init_gherkin_lexer_<%= @i18n %>()
392
+ void Init_gherkin_lexer_<%= @i18n.sanitized_key %>()
391
393
  {
392
394
  mGherkin = rb_define_module("Gherkin");
393
395
  mLexer = rb_const_get(mGherkin, rb_intern("Lexer"));
394
396
  rb_eGherkinLexerError = rb_const_get(mLexer, rb_intern("LexingError"));
395
397
 
396
398
  mCLexer = rb_define_module_under(mGherkin, "CLexer");
397
- cI18nLexer = rb_define_class_under(mCLexer, "<%= @i18n.capitalize %>", rb_cObject);
399
+ cI18nLexer = rb_define_class_under(mCLexer, "<%= @i18n.sanitized_key.capitalize %>", rb_cObject);
398
400
  rb_define_alloc_func(cI18nLexer, CLexer_alloc);
399
401
  rb_define_method(cI18nLexer, "initialize", CLexer_init, 1);
400
402
  rb_define_method(cI18nLexer, "scan", CLexer_scan, 1);
@@ -7,7 +7,7 @@ import gherkin.Lexer;
7
7
  import gherkin.Listener;
8
8
  import gherkin.LexingError;
9
9
 
10
- public class <%= @i18n.capitalize %> implements Lexer {
10
+ public class <%= @i18n.sanitized_key.capitalize %> implements Lexer {
11
11
  %%{
12
12
  machine lexer;
13
13
  alphtype byte;
@@ -136,12 +136,12 @@ public class <%= @i18n.capitalize %> implements Lexer {
136
136
  }
137
137
  }
138
138
 
139
- include lexer_common "lexer_common.<%= @i18n %>.rl";
139
+ include lexer_common "lexer_common.<%= @i18n.sanitized_key %>.rl";
140
140
  }%%
141
141
 
142
142
  private final Listener listener;
143
143
 
144
- public <%= @i18n.capitalize %>(Listener listener) {
144
+ public <%= @i18n.sanitized_key.capitalize %>(Listener listener) {
145
145
  this.listener = listener;
146
146
  }
147
147
 
@@ -2,7 +2,7 @@ require 'gherkin/core_ext/array'
2
2
 
3
3
  module Gherkin
4
4
  module RbLexer
5
- class <%= @i18n.capitalize %> #:nodoc:
5
+ class <%= @i18n.sanitized_key.capitalize %> #:nodoc:
6
6
  %%{
7
7
  machine lexer;
8
8
 
@@ -129,7 +129,7 @@ module Gherkin
129
129
  end
130
130
  }
131
131
 
132
- include lexer_common "lexer_common.<%= @i18n %>.rl";
132
+ include lexer_common "lexer_common.<%= @i18n.sanitized_key %>.rl";
133
133
  }%%
134
134
 
135
135
  def initialize(listener)
@@ -2,12 +2,12 @@
2
2
  machine lexer_common;
3
3
 
4
4
  # Language specific
5
- I18N_Feature = <%= keywords['feature'] %> >start_keyword %end_keyword;
6
- I18N_Background = <%= keywords['background'] %> >start_keyword %end_keyword;
7
- I18N_ScenarioOutline = <%= keywords['scenario_outline'] %> >start_keyword %end_keyword;
8
- I18N_Scenario = <%= keywords['scenario'] %> >start_keyword %end_keyword;
9
- I18N_Step = (<%= keywords['given'] %> | <%= keywords['when'] %> | <%= keywords['and'] %> | <%= keywords['then'] %> | <%= keywords['but'] %>) >start_keyword %end_keyword;
10
- I18N_Examples = <%= keywords['examples'] %> >start_keyword %end_keyword;
5
+ I18N_Feature = (<%= ragel_list(@i18n.feature_keywords) %> ':') >start_keyword %end_keyword;
6
+ I18N_Background = (<%= ragel_list(@i18n.background_keywords) %> ':') >start_keyword %end_keyword;
7
+ I18N_ScenarioOutline = (<%= ragel_list(@i18n.scenario_outline_keywords) %> ':') >start_keyword %end_keyword;
8
+ I18N_Scenario = (<%= ragel_list(@i18n.scenario_keywords) %> ':') >start_keyword %end_keyword;
9
+ I18N_Step = <%= ragel_list(@i18n.step_keywords) %> >start_keyword %end_keyword;
10
+ I18N_Examples = (<%= ragel_list(@i18n.examples_keywords) %> ':') >start_keyword %end_keyword;
11
11
 
12
12
  EOF = '%_FEATURE_END_%'; # Explicit EOF added before scanning begins
13
13
  EOL = ('\r'? '\n') @inc_line_number @last_newline;
@@ -73,8 +73,8 @@ class Benchmarker
73
73
 
74
74
  def report_all
75
75
  Benchmark.bmbm do |x|
76
- x.report("c_gherkin:") { run_c_gherkin }
77
- x.report("c_gherkin_no_parser:") { run_c_gherkin_no_parser }
76
+ x.report("native_gherkin:") { run_native_gherkin }
77
+ x.report("native_gherkin_no_parser:") { run_native_gherkin_no_parser }
78
78
  x.report("rb_gherkin:") { run_rb_gherkin }
79
79
  x.report("cucumber:") { run_cucumber }
80
80
  x.report("tt:") { run_tt }
@@ -115,21 +115,21 @@ class Benchmarker
115
115
  end
116
116
  end
117
117
 
118
- def run_c_gherkin
118
+ def run_native_gherkin
119
119
  require 'gherkin'
120
120
  require 'null_listener'
121
121
  @features.each do |feature|
122
122
  parser = Gherkin::Parser.new(NullListener.new, true, "root")
123
- lexer = Gherkin::CLexer['en'].new(parser)
123
+ lexer = Gherkin::Lexer['en'].new(parser)
124
124
  lexer.scan(File.read(feature))
125
125
  end
126
126
  end
127
127
 
128
- def run_c_gherkin_no_parser
128
+ def run_native_gherkin_no_parser
129
129
  require 'gherkin'
130
130
  require 'null_listener'
131
131
  @features.each do |feature|
132
- lexer = Gherkin::CLexer['en'].new(NullListener.new)
132
+ lexer = Gherkin::Lexer['en'].new(NullListener.new)
133
133
  lexer.scan(File.read(feature))
134
134
  end
135
135
  end
@@ -167,16 +167,16 @@ namespace :bench do
167
167
  benchmarker.report("rb_gherkin")
168
168
  end
169
169
 
170
- desc "Benchmark the C Gherkin lexer+parser with the features in tasks/bench/generated"
171
- task :c_gherkin do
170
+ desc "Benchmark the ntive Gherkin lexer+parser with the features in tasks/bench/generated"
171
+ task :native_gherkin do
172
172
  benchmarker = Benchmarker.new
173
- benchmarker.report("c_gherkin")
173
+ benchmarker.report("native_gherkin")
174
174
  end
175
175
 
176
- desc "Benchmark the C Gherkin lexer (no parser) with the features in tasks/bench/generated"
177
- task :c_gherkin_no_parser do
176
+ desc "Benchmark the native Gherkin lexer (no parser) with the features in tasks/bench/generated"
177
+ task :native_gherkin_no_parser do
178
178
  benchmarker = Benchmarker.new
179
- benchmarker.report("c_gherkin_no_parser")
179
+ benchmarker.report("native_gherkin_no_parser")
180
180
  end
181
181
 
182
182
  desc "Show basic statistics about the features in tasks/bench/generated"
@@ -1,4 +1,5 @@
1
1
  require File.dirname(__FILE__) + '/ragel_task'
2
+ require 'gherkin/i18n'
2
3
 
3
4
  CLEAN.include [
4
5
  '**/*.{o,bundle,jar,so,obj,pdb,lib,def,exp,log}', 'ext',
@@ -14,34 +15,33 @@ task :jar do
14
15
  sh("ant -f java/build.xml")
15
16
  end
16
17
 
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)
18
+ Gherkin::I18n.all.each do |i18n|
19
+ java = RagelTask.new('java', i18n)
20
+ rb = RagelTask.new('rb', i18n)
22
21
 
23
22
  task :jar => java.target
24
23
  task :jar => rb.target
25
24
 
26
25
  begin
27
26
  require 'rake/extensiontask'
28
- c = RagelTask.new('c', i18n, keywords)
27
+ c = RagelTask.new('c', i18n)
29
28
 
30
- extconf = "ext/gherkin_lexer_#{i18n}/extconf.rb"
29
+ extconf = "ext/gherkin_lexer_#{i18n.sanitized_key}/extconf.rb"
31
30
 
32
31
  file extconf do
33
32
  FileUtils.mkdir(File.dirname(extconf)) unless File.directory?(File.dirname(extconf))
34
33
  File.open(extconf, "w") do |io|
35
34
  io.write(<<-EOF)
36
35
  require 'mkmf'
37
- dir_config("gherkin_lexer_#{i18n}")
36
+ $CFLAGS << ' -O0 -Wall -Werror'
37
+ dir_config("gherkin_lexer_#{i18n.sanitized_key}")
38
38
  have_library("c", "main")
39
- create_makefile("gherkin_lexer_#{i18n}")
39
+ create_makefile("gherkin_lexer_#{i18n.sanitized_key}")
40
40
  EOF
41
41
  end
42
42
  end
43
43
 
44
- Rake::ExtensionTask.new("gherkin_lexer_#{i18n}") do |ext|
44
+ Rake::ExtensionTask.new("gherkin_lexer_#{i18n.sanitized_key}") do |ext|
45
45
  if ENV['RUBY_CC_VERSION']
46
46
  ext.cross_compile = true
47
47
  ext.cross_platform = 'i386-mingw32'
@@ -53,9 +53,9 @@ EOF
53
53
 
54
54
  # The way tasks are defined with compile:xxx (but without namespace) in rake-compiler forces us
55
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)
56
+ Rake::Task["compile:gherkin_lexer_#{i18n.sanitized_key}"].prerequisites.unshift(extconf)
57
+ Rake::Task["compile:gherkin_lexer_#{i18n.sanitized_key}"].prerequisites.unshift(c.target)
58
+ Rake::Task["compile:gherkin_lexer_#{i18n.sanitized_key}"].prerequisites.unshift(rb.target)
59
59
 
60
60
  Rake::Task["compile"].prerequisites.unshift(extconf)
61
61
  Rake::Task["compile"].prerequisites.unshift(c.target)
@@ -4,10 +4,9 @@ require 'erb'
4
4
  class RagelTask
5
5
  RL_OUTPUT_DIR = File.dirname(__FILE__) + "/../ragel/i18n"
6
6
 
7
- def initialize(lang, i18n, keywords)
7
+ def initialize(lang, i18n)
8
8
  @lang = lang
9
9
  @i18n = i18n
10
- @keywords = keywords
11
10
  define_tasks
12
11
  end
13
12
 
@@ -18,27 +17,24 @@ class RagelTask
18
17
  end
19
18
 
20
19
  file lang_ragel => lang_erb do
21
- impl = ERB.new(IO.read(lang_erb)).result(binding)
22
- write(impl, lang_ragel)
20
+ write(ERB.new(IO.read(lang_erb)).result(binding), lang_ragel)
23
21
  end
24
22
 
25
23
  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)
24
+ write(ERB.new(IO.read(common_erb)).result(binding), common_ragel)
29
25
  end
30
26
  end
31
27
 
32
28
  def target
33
29
  {
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"
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"
37
33
  }[@lang]
38
34
  end
39
35
 
40
36
  def common_ragel
41
- RL_OUTPUT_DIR + "/lexer_common.#{@i18n}.rl"
37
+ RL_OUTPUT_DIR + "/lexer_common.#{@i18n.sanitized_key}.rl"
42
38
  end
43
39
 
44
40
  def common_erb
@@ -46,7 +42,7 @@ class RagelTask
46
42
  end
47
43
 
48
44
  def lang_ragel
49
- RL_OUTPUT_DIR + "/#{@i18n}.#{@lang}.rl"
45
+ RL_OUTPUT_DIR + "/#{@i18n.sanitized_key}.#{@lang}.rl"
50
46
  end
51
47
 
52
48
  def lang_erb
@@ -61,23 +57,14 @@ class RagelTask
61
57
  }[@lang]
62
58
  end
63
59
 
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
60
  def write(content, filename)
78
61
  mkdir_p(File.dirname(filename)) unless File.directory?(File.dirname(filename))
79
62
  File.open(filename, "wb") do |file|
80
63
  file.write(content)
81
64
  end
82
- end
65
+ end
66
+
67
+ def ragel_list(keywords)
68
+ "(#{keywords.map{|keyword| %{"#{keyword}"}}.join(' | ')})"
69
+ end
83
70
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gherkin
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mike Sassak
@@ -11,7 +11,7 @@ autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
13
 
14
- date: 2009-11-28 00:00:00 +01:00
14
+ date: 2009-12-01 00:00:00 +01:00
15
15
  default_executable: gherkin
16
16
  dependencies:
17
17
  - !ruby/object:Gem::Dependency
@@ -48,47 +48,8 @@ description: A fast Gherkin lexer in Ragel
48
48
  email: cukes@googlegroups.com
49
49
  executables:
50
50
  - gherkin
51
- extensions:
52
- - ext/gherkin_lexer_ar/extconf.rb
53
- - ext/gherkin_lexer_bg/extconf.rb
54
- - ext/gherkin_lexer_cat/extconf.rb
55
- - ext/gherkin_lexer_cs/extconf.rb
56
- - ext/gherkin_lexer_cy/extconf.rb
57
- - ext/gherkin_lexer_da/extconf.rb
58
- - ext/gherkin_lexer_de/extconf.rb
59
- - ext/gherkin_lexer_en/extconf.rb
60
- - ext/gherkin_lexer_enau/extconf.rb
61
- - ext/gherkin_lexer_enlol/extconf.rb
62
- - ext/gherkin_lexer_entx/extconf.rb
63
- - ext/gherkin_lexer_es/extconf.rb
64
- - ext/gherkin_lexer_et/extconf.rb
65
- - ext/gherkin_lexer_fi/extconf.rb
66
- - ext/gherkin_lexer_fr/extconf.rb
67
- - ext/gherkin_lexer_he/extconf.rb
68
- - ext/gherkin_lexer_hr/extconf.rb
69
- - ext/gherkin_lexer_hu/extconf.rb
70
- - ext/gherkin_lexer_id/extconf.rb
71
- - ext/gherkin_lexer_it/extconf.rb
72
- - ext/gherkin_lexer_ja/extconf.rb
73
- - ext/gherkin_lexer_ko/extconf.rb
74
- - ext/gherkin_lexer_lt/extconf.rb
75
- - ext/gherkin_lexer_lv/extconf.rb
76
- - ext/gherkin_lexer_nl/extconf.rb
77
- - ext/gherkin_lexer_no/extconf.rb
78
- - ext/gherkin_lexer_pl/extconf.rb
79
- - ext/gherkin_lexer_pt/extconf.rb
80
- - ext/gherkin_lexer_ro/extconf.rb
81
- - ext/gherkin_lexer_ro2/extconf.rb
82
- - ext/gherkin_lexer_ru/extconf.rb
83
- - ext/gherkin_lexer_se/extconf.rb
84
- - ext/gherkin_lexer_sk/extconf.rb
85
- - ext/gherkin_lexer_sr/extconf.rb
86
- - ext/gherkin_lexer_srLatn/extconf.rb
87
- - ext/gherkin_lexer_tr/extconf.rb
88
- - ext/gherkin_lexer_uz/extconf.rb
89
- - ext/gherkin_lexer_vi/extconf.rb
90
- - ext/gherkin_lexer_zhCN/extconf.rb
91
- - ext/gherkin_lexer_zhTW/extconf.rb
51
+ extensions: []
52
+
92
53
  extra_rdoc_files:
93
54
  - LICENSE
94
55
  - README.rdoc
@@ -100,46 +61,6 @@ files:
100
61
  - VERSION.yml
101
62
  - bin/gherkin
102
63
  - cucumber.yml
103
- - ext/gherkin_lexer_ar/gherkin_lexer_ar.c
104
- - ext/gherkin_lexer_bg/gherkin_lexer_bg.c
105
- - ext/gherkin_lexer_cat/gherkin_lexer_cat.c
106
- - ext/gherkin_lexer_cs/gherkin_lexer_cs.c
107
- - ext/gherkin_lexer_cy/gherkin_lexer_cy.c
108
- - ext/gherkin_lexer_da/gherkin_lexer_da.c
109
- - ext/gherkin_lexer_de/gherkin_lexer_de.c
110
- - ext/gherkin_lexer_en/gherkin_lexer_en.c
111
- - ext/gherkin_lexer_enau/gherkin_lexer_enau.c
112
- - ext/gherkin_lexer_enlol/gherkin_lexer_enlol.c
113
- - ext/gherkin_lexer_entx/gherkin_lexer_entx.c
114
- - ext/gherkin_lexer_es/gherkin_lexer_es.c
115
- - ext/gherkin_lexer_et/gherkin_lexer_et.c
116
- - ext/gherkin_lexer_fi/gherkin_lexer_fi.c
117
- - ext/gherkin_lexer_fr/gherkin_lexer_fr.c
118
- - ext/gherkin_lexer_he/gherkin_lexer_he.c
119
- - ext/gherkin_lexer_hr/gherkin_lexer_hr.c
120
- - ext/gherkin_lexer_hu/gherkin_lexer_hu.c
121
- - ext/gherkin_lexer_id/gherkin_lexer_id.c
122
- - ext/gherkin_lexer_it/gherkin_lexer_it.c
123
- - ext/gherkin_lexer_ja/gherkin_lexer_ja.c
124
- - ext/gherkin_lexer_ko/gherkin_lexer_ko.c
125
- - ext/gherkin_lexer_lt/gherkin_lexer_lt.c
126
- - ext/gherkin_lexer_lv/gherkin_lexer_lv.c
127
- - ext/gherkin_lexer_nl/gherkin_lexer_nl.c
128
- - ext/gherkin_lexer_no/gherkin_lexer_no.c
129
- - ext/gherkin_lexer_pl/gherkin_lexer_pl.c
130
- - ext/gherkin_lexer_pt/gherkin_lexer_pt.c
131
- - ext/gherkin_lexer_ro/gherkin_lexer_ro.c
132
- - ext/gherkin_lexer_ro2/gherkin_lexer_ro2.c
133
- - ext/gherkin_lexer_ru/gherkin_lexer_ru.c
134
- - ext/gherkin_lexer_se/gherkin_lexer_se.c
135
- - ext/gherkin_lexer_sk/gherkin_lexer_sk.c
136
- - ext/gherkin_lexer_sr/gherkin_lexer_sr.c
137
- - ext/gherkin_lexer_srLatn/gherkin_lexer_srLatn.c
138
- - ext/gherkin_lexer_tr/gherkin_lexer_tr.c
139
- - ext/gherkin_lexer_uz/gherkin_lexer_uz.c
140
- - ext/gherkin_lexer_vi/gherkin_lexer_vi.c
141
- - ext/gherkin_lexer_zhCN/gherkin_lexer_zhCN.c
142
- - ext/gherkin_lexer_zhTW/gherkin_lexer_zhTW.c
143
64
  - features/feature_parser.feature
144
65
  - features/native_lexer.feature
145
66
  - features/parser_with_native_lexer.feature
@@ -164,6 +85,7 @@ files:
164
85
  - lib/gherkin.rb
165
86
  - lib/gherkin/c_lexer.rb
166
87
  - lib/gherkin/core_ext/array.rb
88
+ - lib/gherkin/i18n.rb
167
89
  - lib/gherkin/i18n.yml
168
90
  - lib/gherkin/i18n_lexer.rb
169
91
  - lib/gherkin/java_lexer.rb