gherkin 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore CHANGED
@@ -3,6 +3,5 @@
3
3
  coverage
4
4
  rdoc
5
5
  pkg
6
- *.dot
7
- *.png
8
- *.so
6
+ ext
7
+ tmp
@@ -17,6 +17,25 @@ rake spec cucumber
17
17
 
18
18
  rake clobber
19
19
 
20
+ == Release process
21
+
22
+ Run just "rake" for each platform (1.8.6, 1.8.7, 1.9, jruby) to make sure all is green.
23
+
24
+ 1) Bump version in the VERSION file
25
+ 2) rake gemspec
26
+ 3) Commit everything
27
+ 4) rake release
28
+ 5) ./nativegems.sh
29
+ 6) gem push pkg/... (for each native gem)
30
+
31
+ TODO: Also build windows gem with dll using rake-compiler. MinGW gem can be done on OS X/Linux, but
32
+ the one for the old Ruby one-click installers must be built with Visual Studio/nmake.
33
+
34
+ == Build windows gems on OS X
35
+
36
+ * http://www.copiousfreetime.org/articles/2008/10/12/building-gems-for-windows.html
37
+ * rake-compiler docs
38
+
20
39
  == Notes
21
40
 
22
41
  Ragel supports Ruby, but it's much slower than C. The ruby target will be used for development.
data/Rakefile CHANGED
@@ -4,9 +4,6 @@ require 'rubygems'
4
4
  require 'rake'
5
5
  require 'rake/clean'
6
6
 
7
- JRUBY = defined?(JRUBY_VERSION)
8
- WINDOWS = Config::CONFIG['host_os'] =~ /mswin|mingw/
9
-
10
7
  begin
11
8
  require 'jeweler'
12
9
  Jeweler::Tasks.new do |gem|
@@ -18,22 +15,26 @@ begin
18
15
  gem.authors = ["Mike Sassak", "Gregory Hnatiuk", "Aslak Hellesøy"]
19
16
  gem.executables = ["gherkin"]
20
17
  gem.add_development_dependency "rspec", "1.2.9"
21
- gem.add_development_dependency "cucumber"
18
+ gem.add_development_dependency "cucumber", "0.4.4"
19
+ gem.add_development_dependency "rake-compiler", "0.6.0" unless defined?(JRUBY_VERSION)
22
20
 
23
- # Jeweler only includes files in git by default. Add the generated ones.
24
- gem.files += FileList['lib/gherkin/rb_lexer/*.rb']
25
-
26
- if(JRUBY)
27
- gem.platform = Gem::Platform::CURRENT
21
+ case ENV['PLATFORM']
22
+ when 'universal-java-1.5'
23
+ gem.platform = 'universal-java-1.5'
28
24
  gem.files += FileList['lib/gherkin.jar']
29
25
  gem.extensions = []
30
- elsif(WINDOWS)
31
- gem.platform = Gem::Platform::CURRENT
32
- gem.files += FileList['lib/gherkin_lexer.dll']
26
+ when 'i386-mswin32'
27
+ gem.platform = 'i386-mswin32'
28
+ gem.files += FileList['lib/*.so']
29
+ gem.extensions = []
30
+ when 'i386-mingw32'
31
+ gem.platform = 'i386-mingw32'
32
+ gem.files += FileList['lib/*.so']
33
33
  gem.extensions = []
34
34
  else
35
- gem.files += FileList['ext/gherkin_lexer/*.{c,h}']
36
- gem.extensions = 'ext/gherkin_lexer/extconf.rb'
35
+ gem.files += FileList['lib/gherkin/rb_lexer/*.rb']
36
+ gem.files += FileList['ext/**/*.c']
37
+ gem.extensions = FileList['ext/**/extconf.rb']
37
38
  end
38
39
 
39
40
  # gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
@@ -45,4 +46,4 @@ end
45
46
 
46
47
  Dir['tasks/**/*.rake'].each { |rake| load rake }
47
48
 
48
- task :default => [:spec, :cucumber]
49
+ task :default => [:jar, :compile, :spec, :cucumber]
@@ -1,4 +1,4 @@
1
1
  ---
2
2
  :minor: 0
3
- :patch: 3
3
+ :patch: 4
4
4
  :major: 0
@@ -6,5 +6,5 @@ require 'gherkin/tools/pretty_printer'
6
6
 
7
7
  listener = Gherkin::Tools::PrettyPrinter.new(STDOUT)
8
8
  parser = Gherkin::Parser.new(listener, true) # We could skip the parser here, if we don't want to verify well-formedness
9
- lexer = Gherkin::Lexer['en'].new(parser)
10
- lexer.scan(IO.read(ARGV[0]))
9
+ lexer = Gherkin::I18nLexer.new(parser)
10
+ lexer.scan(IO.read(ARGV[0]))
@@ -6,6 +6,9 @@ Feature: Pretty printer
6
6
  Given I have Cucumber's home dir defined in CUCUMBER_HOME
7
7
  When I find all of the .feature files
8
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.
9
+ # Of course, we don't really want any errors. The last
10
+ # two files that were not identical are written to p1.feature
11
+ # and p2.feature. Do a diff -u p1.feature p2.feature
12
+ #
10
13
  Then the following files should have errors:
11
- | Path | Error |
14
+ | Path | Error |
@@ -1,4 +1,5 @@
1
1
  require 'stringio'
2
+ require 'gherkin'
2
3
  require 'gherkin/tools/pretty_printer'
3
4
 
4
5
  module PrettyPlease
@@ -27,12 +28,16 @@ end
27
28
  When /^I parse the prettified representation of each of them$/ do
28
29
  @errors = [['Path', 'Error']]
29
30
  @features.each do |feature|
31
+ pretty1 = nil
32
+ pretty2 = nil
30
33
  begin
34
+ # announce "========== #{feature}:"
31
35
  pretty1 = pretty(IO.read(feature))
32
36
  pretty2 = pretty(pretty1)
33
-
34
37
  pretty2.should == pretty1
35
38
  rescue Spec::Expectations::ExpectationNotMetError => e
39
+ File.open("p1.feature", "w") {|io| io.write(pretty1)}
40
+ File.open("p2.feature", "w") {|io| io.write(pretty2)}
36
41
  announce "========== #{feature}:"
37
42
  if(e.message =~ /(@@.*)/m)
38
43
  announce $1
@@ -5,16 +5,16 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{gherkin}
8
- s.version = "0.0.3"
8
+ s.version = "0.0.4"
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-25}
12
+ s.date = %q{2009-11-28}
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/extconf.rb"]
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
18
  s.extra_rdoc_files = [
19
19
  "LICENSE",
20
20
  "README.rdoc"
@@ -27,9 +27,46 @@ Gem::Specification.new do |s|
27
27
  "VERSION.yml",
28
28
  "bin/gherkin",
29
29
  "cucumber.yml",
30
- "ext/gherkin_lexer/.gitignore",
31
- "ext/gherkin_lexer/en.c",
32
- "ext/gherkin_lexer/extconf.rb",
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",
33
70
  "features/feature_parser.feature",
34
71
  "features/native_lexer.feature",
35
72
  "features/parser_with_native_lexer.feature",
@@ -53,6 +90,7 @@ Gem::Specification.new do |s|
53
90
  "lib/.gitignore",
54
91
  "lib/gherkin.rb",
55
92
  "lib/gherkin/c_lexer.rb",
93
+ "lib/gherkin/core_ext/array.rb",
56
94
  "lib/gherkin/i18n.yml",
57
95
  "lib/gherkin/i18n_lexer.rb",
58
96
  "lib/gherkin/java_lexer.rb",
@@ -71,10 +109,10 @@ Gem::Specification.new do |s|
71
109
  "lib/gherkin/rb_lexer/cy.rb",
72
110
  "lib/gherkin/rb_lexer/da.rb",
73
111
  "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
112
  "lib/gherkin/rb_lexer/en.rb",
113
+ "lib/gherkin/rb_lexer/enau.rb",
114
+ "lib/gherkin/rb_lexer/enlol.rb",
115
+ "lib/gherkin/rb_lexer/entx.rb",
78
116
  "lib/gherkin/rb_lexer/es.rb",
79
117
  "lib/gherkin/rb_lexer/et.rb",
80
118
  "lib/gherkin/rb_lexer/fi.rb",
@@ -97,21 +135,23 @@ Gem::Specification.new do |s|
97
135
  "lib/gherkin/rb_lexer/ru.rb",
98
136
  "lib/gherkin/rb_lexer/se.rb",
99
137
  "lib/gherkin/rb_lexer/sk.rb",
100
- "lib/gherkin/rb_lexer/sr-Latn.rb",
101
138
  "lib/gherkin/rb_lexer/sr.rb",
139
+ "lib/gherkin/rb_lexer/srLatn.rb",
102
140
  "lib/gherkin/rb_lexer/tr.rb",
103
141
  "lib/gherkin/rb_lexer/uz.rb",
104
142
  "lib/gherkin/rb_lexer/vi.rb",
105
- "lib/gherkin/rb_lexer/zh-CN.rb",
106
- "lib/gherkin/rb_lexer/zh-TW.rb",
143
+ "lib/gherkin/rb_lexer/zhCN.rb",
144
+ "lib/gherkin/rb_lexer/zhTW.rb",
107
145
  "lib/gherkin/rb_parser.rb",
108
146
  "lib/gherkin/tools/pretty_printer.rb",
147
+ "nativegems.sh",
109
148
  "ragel/i18n/.gitignore",
110
149
  "ragel/lexer.c.rl.erb",
111
150
  "ragel/lexer.java.rl.erb",
112
151
  "ragel/lexer.rb.rl.erb",
113
152
  "ragel/lexer_common.rl.erb",
114
153
  "spec/gherkin/c_lexer_spec.rb",
154
+ "spec/gherkin/fixtures/1.feature",
115
155
  "spec/gherkin/fixtures/complex.feature",
116
156
  "spec/gherkin/fixtures/i18n_fr.feature",
117
157
  "spec/gherkin/fixtures/i18n_no.feature",
@@ -133,9 +173,9 @@ Gem::Specification.new do |s|
133
173
  "tasks/bench/feature_builder.rb",
134
174
  "tasks/bench/generated/.gitignore",
135
175
  "tasks/bench/null_listener.rb",
176
+ "tasks/compile.rake",
136
177
  "tasks/cucumber.rake",
137
- "tasks/ext.rake",
138
- "tasks/ragel.rake",
178
+ "tasks/ragel_task.rb",
139
179
  "tasks/rdoc.rake",
140
180
  "tasks/rspec.rake"
141
181
  ]
@@ -164,14 +204,17 @@ Gem::Specification.new do |s|
164
204
 
165
205
  if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
166
206
  s.add_development_dependency(%q<rspec>, ["= 1.2.9"])
167
- s.add_development_dependency(%q<cucumber>, [">= 0"])
207
+ s.add_development_dependency(%q<cucumber>, ["= 0.4.4"])
208
+ s.add_development_dependency(%q<rake-compiler>, ["= 0.6.0"])
168
209
  else
169
210
  s.add_dependency(%q<rspec>, ["= 1.2.9"])
170
- s.add_dependency(%q<cucumber>, [">= 0"])
211
+ s.add_dependency(%q<cucumber>, ["= 0.4.4"])
212
+ s.add_dependency(%q<rake-compiler>, ["= 0.6.0"])
171
213
  end
172
214
  else
173
215
  s.add_dependency(%q<rspec>, ["= 1.2.9"])
174
- s.add_dependency(%q<cucumber>, [">= 0"])
216
+ s.add_dependency(%q<cucumber>, ["= 0.4.4"])
217
+ s.add_dependency(%q<rake-compiler>, ["= 0.6.0"])
175
218
  end
176
219
  end
177
220
 
@@ -1,2 +1,4 @@
1
- gherkin_lexer.bundle
2
- gherkin.jar
1
+ *.bundle
2
+ *.dll
3
+ *.so
4
+ *.jar
@@ -1,9 +1,9 @@
1
- require 'gherkin_lexer'
2
-
3
1
  module Gherkin
4
2
  module CLexer
5
3
  def self.[](i18n_language)
6
- i18n_lexer_class_name = i18n_language.gsub(/[\s-]/, '').capitalize
4
+ name = i18n_language.gsub(/[\s-]/, '')
5
+ require "gherkin_lexer_#{name}"
6
+ i18n_lexer_class_name = name.capitalize
7
7
  const_get(i18n_lexer_class_name)
8
8
  end
9
9
  end
@@ -0,0 +1,5 @@
1
+ class Array
2
+ def utf8_pack(fmt)
3
+ (RUBY_VERSION =~ /^1\.9/) ? pack(fmt).force_encoding("UTF-8") : pack(fmt)
4
+ end
5
+ end
@@ -6,20 +6,21 @@ module Gherkin
6
6
  class << self
7
7
  def [](i18n_lang)
8
8
  begin
9
+ # Uncomment the line below (during development) to force use of Ruby lexer
10
+ # return rb[i18n_lang]
11
+
9
12
  if defined?(JRUBY_VERSION)
10
13
  java[i18n_lang]
11
14
  else
12
15
  begin
13
16
  c[i18n_lang]
14
- rescue NameError => e
17
+ rescue NameError, LoadError => e
15
18
  warn("WARNING: #{e.message}. Reverting to Ruby lexer")
16
19
  rb[i18n_lang]
17
- rescue LoadError
18
- rb[i18n_lang]
19
20
  end
20
21
  end
21
- rescue LoadError
22
- raise I18nLexerNotFound, "No lexer was found for #{i18n_lang}. Supported languages are listed in gherkin/i18n.yml."
22
+ rescue LoadError => e
23
+ raise I18nLexerNotFound, "No lexer was found for #{i18n_lang} (#{e.message}). Supported languages are listed in gherkin/i18n.yml."
23
24
  end
24
25
  end
25
26
 
@@ -1,8 +1,9 @@
1
1
  module Gherkin
2
2
  module RbLexer
3
3
  def self.[](i18n_language)
4
- require "gherkin/rb_lexer/#{i18n_language}"
5
- i18n_lexer_class_name = i18n_language.gsub(/[\s-]/, '').capitalize
4
+ name = i18n_language.gsub(/[\s-]/, '')
5
+ require "gherkin/rb_lexer/#{name}"
6
+ i18n_lexer_class_name = name.capitalize
6
7
  const_get(i18n_lexer_class_name)
7
8
  end
8
9
  end
@@ -1,3 +1,4 @@
1
+ # encoding: utf-8
1
2
  module Gherkin
2
3
  module Tools
3
4
  class PrettyPrinter
@@ -53,9 +54,7 @@ module Gherkin
53
54
  end
54
55
 
55
56
  def py_string(string, line)
56
- @io.puts ' """'
57
- @io.puts string.gsub(/^/, ' ')
58
- @io.puts ' """'
57
+ @io.puts " \"\"\"\n" + string.gsub(START, ' ') + "\n \"\"\""
59
58
  end
60
59
 
61
60
  def syntax_error(state, event, legal_events, line)
@@ -63,10 +62,17 @@ module Gherkin
63
62
  end
64
63
 
65
64
  private
65
+ if(RUBY_VERSION =~ /^1\.9/)
66
+ START = /#{"^".encode('UTF-8')}/
67
+ NL = Regexp.new("\n".encode('UTF-8'))
68
+ else
69
+ START = /^/
70
+ NL = /\n/n
71
+ end
66
72
 
67
73
  def indent(string, indentation)
68
74
  indent = ""
69
- string.split(/\n/n).map do |l|
75
+ string.split(NL).map do |l|
70
76
  s = "#{indent}#{l}"
71
77
  indent = indentation
72
78
  s
@@ -0,0 +1,5 @@
1
+ #!/bin/sh
2
+ # Builds gems for all supported platforms
3
+ rake gemspec build PLATFORM=universal-java-1.5
4
+ rake cross compile gemspec build PLATFORM=i386-mswin32 RUBY_CC_VERSION=1.8.6
5
+ rake gemspec build PLATFORM=i386-mingw32 RUBY_CC_VERSION=1.8.6
@@ -5,6 +5,19 @@
5
5
  #include <stddef.h>
6
6
  #endif
7
7
 
8
+ #ifdef HAVE_RUBY_RE_H
9
+ #include <ruby/re.h>
10
+ #endif
11
+
12
+ #ifdef HAVE_RUBY_ENCODING_H
13
+ #include <ruby/encoding.h>
14
+ #define ENCODED_STR_NEW(ptr, len) \
15
+ rb_enc_str_new(ptr, len, rb_utf8_encoding());
16
+ #else
17
+ #define ENCODED_STR_NEW(ptr, len) \
18
+ rb_str_new(ptr, len);
19
+ #endif
20
+
8
21
  #ifndef RSTRING_PTR
9
22
  #define RSTRING_PTR(s) (RSTRING(s)->ptr)
10
23
  #endif
@@ -115,10 +128,12 @@ static VALUE rb_eGherkinLexerError;
115
128
 
116
129
  action store_comment_content {
117
130
  STORE_ATTR(comment)
131
+ lexer->mark = 0;
118
132
  }
119
133
 
120
134
  action store_tag_content {
121
135
  STORE_ATTR(tag)
136
+ lexer->mark = 0;
122
137
  }
123
138
 
124
139
  action inc_line_number {
@@ -160,7 +175,7 @@ static VALUE rb_eGherkinLexerError;
160
175
 
161
176
  action store_cell_content {
162
177
  VALUE con = Qnil;
163
- con = rb_str_new(PTR_TO(content_start), LEN(content_start, p));
178
+ con = ENCODED_STR_NEW(PTR_TO(content_start), LEN(content_start, p));
164
179
  rb_funcall(con, rb_intern("strip!"), 0);
165
180
 
166
181
  rb_ary_push(current_row, con);
@@ -217,7 +232,7 @@ static VALUE rb_eGherkinLexerError;
217
232
  }
218
233
  }
219
234
 
220
- include lexer_common "lexer_common.<%= i18n_language %>.rl";
235
+ include lexer_common "lexer_common.<%= @i18n %>.rl";
221
236
 
222
237
  }%%
223
238
 
@@ -251,8 +266,8 @@ store_kw_con(VALUE listener, const char * event_name,
251
266
  int current_line)
252
267
  {
253
268
  VALUE con = Qnil, kw = Qnil;
254
- kw = rb_str_new(keyword_at, keyword_length);
255
- con = rb_str_new(at, length);
269
+ kw = ENCODED_STR_NEW(keyword_at, keyword_length);
270
+ con = ENCODED_STR_NEW(at, length);
256
271
  con = multiline_strip(con);
257
272
  rb_funcall(con, rb_intern("strip!"), 0);
258
273
  rb_funcall(kw, rb_intern("strip!"), 0);
@@ -264,7 +279,7 @@ store_attr(VALUE listener, const char * attr_type,
264
279
  const char * at, size_t length,
265
280
  int line)
266
281
  {
267
- VALUE val = rb_str_new(at, length);
282
+ VALUE val = ENCODED_STR_NEW(at, length);
268
283
  rb_funcall(listener, rb_intern(attr_type), 2, val, INT2FIX(line));
269
284
  }
270
285
 
@@ -274,8 +289,8 @@ store_pystring_content(VALUE listener,
274
289
  const char *at, size_t length,
275
290
  int current_line)
276
291
  {
277
- VALUE con = rb_str_new(at, length);
278
- // Gherkin will crash gracefully if the string representation of start_col pushes the pattern past 64 characters
292
+ VALUE con = ENCODED_STR_NEW(at, length);
293
+ // Gherkin will crash gracefully if the string representation of start_col pushes the pattern past 32 characters
279
294
  char pat[32];
280
295
  snprintf(pat, 32, "^ {0,%d}", start_col);
281
296
  VALUE re = rb_reg_regcomp(rb_str_new2(pat));
@@ -331,9 +346,10 @@ static VALUE CLexer_scan(VALUE self, VALUE input)
331
346
  lexer_state *lexer = NULL;
332
347
  DATA_GET(self, lexer_state, lexer);
333
348
 
334
- rb_str_append(input, rb_str_new2("\n%_FEATURE_END_%"));
335
- char *data = RSTRING_PTR(input);
336
- long len = RSTRING_LEN(input);
349
+ VALUE input_copy = rb_str_dup(input);
350
+ rb_str_append(input_copy, rb_str_new2("\n%_FEATURE_END_%"));
351
+ char *data = RSTRING_PTR(input_copy);
352
+ long len = RSTRING_LEN(input_copy);
337
353
 
338
354
  if (len == 0) {
339
355
  rb_raise(rb_eGherkinLexerError, "No content to lex.");
@@ -371,14 +387,14 @@ static VALUE CLexer_scan(VALUE self, VALUE input)
371
387
  }
372
388
  }
373
389
 
374
- void Init_gherkin_lexer()
390
+ void Init_gherkin_lexer_<%= @i18n %>()
375
391
  {
376
392
  mGherkin = rb_define_module("Gherkin");
377
393
  mLexer = rb_const_get(mGherkin, rb_intern("Lexer"));
378
394
  rb_eGherkinLexerError = rb_const_get(mLexer, rb_intern("LexingError"));
379
395
 
380
396
  mCLexer = rb_define_module_under(mGherkin, "CLexer");
381
- cI18nLexer = rb_define_class_under(mCLexer, "En", rb_cObject);
397
+ cI18nLexer = rb_define_class_under(mCLexer, "<%= @i18n.capitalize %>", rb_cObject);
382
398
  rb_define_alloc_func(cI18nLexer, CLexer_alloc);
383
399
  rb_define_method(cI18nLexer, "initialize", CLexer_init, 1);
384
400
  rb_define_method(cI18nLexer, "scan", CLexer_scan, 1);