gherkin 2.11.3 → 2.11.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -15,7 +15,7 @@ Gem::Specification.new do |s|
15
15
  # When both are building OK, do a `bundle exec rake install` in both cucumber and gherkin projects, revert the changes in the first 2 steps
16
16
  # and release both projects. Do this for both ruby 1.8.7, ruby 1.9.3 and jruby.
17
17
  #
18
- s.version = "2.11.3"
18
+ s.version = "2.11.4"
19
19
  s.authors = ["Mike Sassak", "Gregory Hnatiuk", "Aslak Hellesøy"]
20
20
  s.description = "A fast Gherkin lexer/parser based on the Ragel State Machine Compiler."
21
21
  s.summary = "#{s.name}-#{s.version}"
@@ -237,6 +237,20 @@
237
237
  "and": "*|Ja",
238
238
  "but": "*|Kuid"
239
239
  },
240
+ "fa": {
241
+ "name": "Persian",
242
+ "native": "فارسی",
243
+ "feature": "وِیژگی",
244
+ "background": "زمینه",
245
+ "scenario": "سناریو",
246
+ "scenario_outline": "الگوی سناریو",
247
+ "examples": "نمونه ها",
248
+ "given": "*|با فرض",
249
+ "when": "*|هنگامی",
250
+ "then": "*|آنگاه",
251
+ "and": "*|و",
252
+ "but": "*|اما"
253
+ },
240
254
  "fi": {
241
255
  "name": "Finnish",
242
256
  "native": "suomi",
@@ -0,0 +1,34 @@
1
+ module Gherkin
2
+ module Lexer
3
+ class Encoding
4
+ native_impl('gherkin')
5
+
6
+ COMMENT_OR_EMPTY_LINE_PATTERN = /^\s*#|^\s*$/
7
+ ENCODING_PATTERN = /^\s*#\s*encoding\s*:\s*([0-9a-zA-Z\-]+)/i #:nodoc:
8
+
9
+ def read_file(path)
10
+ source = File.new(path).read
11
+ enc = encoding(source)
12
+ if(enc != 'UTF-8')
13
+ # Read it again with different encoding
14
+ source = File.new(path, "r:#{enc}:UTF-8").read
15
+ end
16
+ source
17
+ end
18
+
19
+ private
20
+
21
+ def encoding(source)
22
+ encoding = 'UTF-8'
23
+ source.each_line do |line|
24
+ break unless COMMENT_OR_EMPTY_LINE_PATTERN =~ line
25
+ if ENCODING_PATTERN =~ line
26
+ encoding = $1
27
+ break
28
+ end
29
+ end
30
+ encoding.upcase
31
+ end
32
+ end
33
+ end
34
+ end
@@ -5,6 +5,7 @@ class Class
5
5
  class << self
6
6
  def new(*args)
7
7
  js = {
8
+ # Add more mappings here if needed. The mappings are only used by test code.
8
9
  'Gherkin::Formatter::JSONFormatter' => 'js/lib/gherkin/formatter/json_formatter.js',
9
10
  'Gherkin::Lexer::En' => 'js/lib/gherkin/lexer/en.js'
10
11
  }[self.name]
@@ -39,7 +39,7 @@ public class <%= @i18n.underscored_iso_code.capitalize %> implements Lexer {
39
39
  }
40
40
 
41
41
  action store_docstring_content {
42
- String con = unindent(startCol, substring(data, contentStart, nextKeywordStart-1).replaceFirst("(\\r?\\n)?([\\t ])*\\Z", "").replaceAll("\\\\\"\\\\\"\\\\\"", "\"\"\""));
42
+ String con = unindent(startCol, substring(data, contentStart, nextKeywordStart-1).replaceFirst("(\\r?\\n)?([\\t ])*\\Z", "").replace("\\\"\\\"\\\"", "\"\"\""));
43
43
  String conType = substring(data, docstringContentTypeStart, docstringContentTypeEnd).trim();
44
44
  listener.docString(conType, con, currentLine);
45
45
  }
@@ -127,9 +127,9 @@ public class <%= @i18n.underscored_iso_code.capitalize %> implements Lexer {
127
127
  action store_cell_content {
128
128
  String con = substring(data, contentStart, p).trim();
129
129
  currentRow.add(con
130
- .replaceAll("\\\\\\|", "|")
131
- .replaceAll("\\\\n", "\n")
132
- .replaceAll("\\\\\\\\", "\\\\")
130
+ .replace("\\|", "|")
131
+ .replace("\\n", "\n")
132
+ .replace("\\\\", "\\")
133
133
  );
134
134
  }
135
135
 
@@ -215,7 +215,7 @@ if(typeof module !== 'undefined') {
215
215
  if (typeof define !== 'undefined') {
216
216
  if(define.amd) {
217
217
  define('gherkin/lexer/<%= @i18n.underscored_iso_code %>', [], function() {
218
- return Lexer
218
+ return Lexer;
219
219
  });
220
220
  } else {
221
221
  define('gherkin/lexer/<%= @i18n.underscored_iso_code %>', function(require, exports, module) {
@@ -15,7 +15,7 @@ module Gherkin
15
15
  it_should_behave_like "a Gherkin lexer lexing tags"
16
16
  it_should_behave_like "a Gherkin lexer lexing doc_strings"
17
17
  it_should_behave_like "a Gherkin lexer lexing rows"
18
- it_should_behave_like "parsing windows files"
18
+ it_should_behave_like "encoding"
19
19
  end
20
20
  end
21
21
  end
@@ -0,0 +1,6 @@
1
+ # language: no
2
+ # encoding: iSo-8859-1
3
+ Egenskap: ISO-8859-1
4
+ Scenario: ���
5
+ N�r this is encoded as Latin-1
6
+ S� everything should parse
@@ -184,6 +184,7 @@ module Gherkin
184
184
  | eo | Esperanto | Esperanto |
185
185
  | es | Spanish | español |
186
186
  | et | Estonian | eesti keel |
187
+ | fa | Persian | فارسی |
187
188
  | fi | Finnish | suomi |
188
189
  | fr | French | français |
189
190
  | he | Hebrew | עברית |
@@ -23,7 +23,7 @@ module Gherkin
23
23
  it_should_behave_like "a Gherkin lexer lexing tags"
24
24
  it_should_behave_like "a Gherkin lexer lexing doc_strings"
25
25
  it_should_behave_like "a Gherkin lexer lexing rows"
26
- it_should_behave_like "parsing windows files" unless ENV['GHERKIN_JS_NATIVE']
26
+ it_should_behave_like "encoding" unless ENV['GHERKIN_JS_NATIVE']
27
27
  end
28
28
  end
29
29
  end
@@ -0,0 +1,36 @@
1
+ #encoding: utf-8
2
+ require 'spec_helper'
3
+
4
+ module Gherkin
5
+ module Lexer
6
+ shared_examples_for "encoding" do
7
+ describe "with BOM" do
8
+ it "should work just fine" do
9
+ scan_file("with_bom.feature")
10
+ @listener.to_sexp.should == [
11
+ [:feature, "Feature", "Feature Text", "", 1],
12
+ [:scenario, "Scenario", "Reading a Scenario", "", 2],
13
+ [:step, "Given ", "there is a step", 3],
14
+ [:eof]
15
+ ]
16
+ end
17
+
18
+ describe "with ISO-8859-1 encoding" do
19
+ it "should work just fine" do
20
+ @lexer = Gherkin::Lexer::I18nLexer.new(@listener)
21
+ scan_file("iso-8859-1.feature")
22
+ @listener.to_sexp.should == [
23
+ [:comment, "# language: no", 1],
24
+ [:comment, "# encoding: iSo-8859-1", 2],
25
+ [:feature, "Egenskap", "ISO-8859-1", "", 3],
26
+ [:scenario, "Scenario", "ÆØÅ", "", 4],
27
+ [:step, "Når ", "this is encoded as Latin-1", 5],
28
+ [:step, "Så ", "everything should parse", 6],
29
+ [:eof]
30
+ ]
31
+ end
32
+ end
33
+ end
34
+ end
35
+ end
36
+ end
@@ -12,11 +12,12 @@ require 'gherkin'
12
12
  require 'stringio'
13
13
  require 'gherkin/sexp_recorder'
14
14
  require 'gherkin/output_stream_string_io'
15
- require 'gherkin/shared/bom_group'
15
+ require 'gherkin/shared/encoding_group'
16
16
  require 'gherkin/shared/lexer_group'
17
17
  require 'gherkin/shared/tags_group'
18
18
  require 'gherkin/shared/doc_string_group'
19
19
  require 'gherkin/shared/row_group'
20
+ require 'gherkin/lexer/encoding'
20
21
  $:.unshift(File.dirname(__FILE__))
21
22
 
22
23
  module GherkinSpecHelper
@@ -25,7 +26,8 @@ module GherkinSpecHelper
25
26
  end
26
27
 
27
28
  def fixture(file)
28
- File.new(File.dirname(__FILE__) + "/gherkin/fixtures/" + file).read
29
+ encoding = Gherkin::Lexer::Encoding.new
30
+ source = encoding.read_file(File.dirname(__FILE__) + "/gherkin/fixtures/" + file)
29
31
  end
30
32
 
31
33
  def rubify_hash(hash)
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: 2.11.3
4
+ version: 2.11.4
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -11,7 +11,7 @@ authors:
11
11
  autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
- date: 2012-10-08 00:00:00.000000000 Z
14
+ date: 2012-10-09 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: rake-compiler
@@ -125,22 +125,6 @@ dependencies:
125
125
  - - ! '>='
126
126
  - !ruby/object:Gem::Version
127
127
  version: 0.9.9
128
- - !ruby/object:Gem::Dependency
129
- name: therubyracer
130
- requirement: !ruby/object:Gem::Requirement
131
- none: false
132
- requirements:
133
- - - ! '>='
134
- - !ruby/object:Gem::Version
135
- version: 0.10.2
136
- type: :development
137
- prerelease: false
138
- version_requirements: !ruby/object:Gem::Requirement
139
- none: false
140
- requirements:
141
- - - ! '>='
142
- - !ruby/object:Gem::Version
143
- version: 0.10.2
144
128
  - !ruby/object:Gem::Dependency
145
129
  name: yard
146
130
  requirement: !ruby/object:Gem::Requirement
@@ -226,6 +210,7 @@ extensions:
226
210
  - ext/gherkin_lexer_eo/extconf.rb
227
211
  - ext/gherkin_lexer_es/extconf.rb
228
212
  - ext/gherkin_lexer_et/extconf.rb
213
+ - ext/gherkin_lexer_fa/extconf.rb
229
214
  - ext/gherkin_lexer_fi/extconf.rb
230
215
  - ext/gherkin_lexer_fr/extconf.rb
231
216
  - ext/gherkin_lexer_he/extconf.rb
@@ -310,6 +295,7 @@ files:
310
295
  - lib/gherkin/i18n.json
311
296
  - lib/gherkin/i18n.rb
312
297
  - lib/gherkin/json_parser.rb
298
+ - lib/gherkin/lexer/encoding.rb
313
299
  - lib/gherkin/lexer/i18n_lexer.rb
314
300
  - lib/gherkin/listener/event.rb
315
301
  - lib/gherkin/listener/formatter_listener.rb
@@ -346,6 +332,7 @@ files:
346
332
  - spec/gherkin/fixtures/i18n_pt3.feature
347
333
  - spec/gherkin/fixtures/i18n_pt4.feature
348
334
  - spec/gherkin/fixtures/i18n_zh-CN.feature
335
+ - spec/gherkin/fixtures/iso-8859-1.feature
349
336
  - spec/gherkin/fixtures/issue_145.feature
350
337
  - spec/gherkin/fixtures/scenario_outline_with_tags.feature
351
338
  - spec/gherkin/fixtures/scenario_without_steps.feature
@@ -369,8 +356,8 @@ files:
369
356
  - spec/gherkin/output_stream_string_io.rb
370
357
  - spec/gherkin/parser/parser_spec.rb
371
358
  - spec/gherkin/sexp_recorder.rb
372
- - spec/gherkin/shared/bom_group.rb
373
359
  - spec/gherkin/shared/doc_string_group.rb
360
+ - spec/gherkin/shared/encoding_group.rb
374
361
  - spec/gherkin/shared/lexer_group.rb
375
362
  - spec/gherkin/shared/row_group.rb
376
363
  - spec/gherkin/shared/tags_group.rb
@@ -411,6 +398,7 @@ files:
411
398
  - ext/gherkin_lexer_eo/gherkin_lexer_eo.c
412
399
  - ext/gherkin_lexer_es/gherkin_lexer_es.c
413
400
  - ext/gherkin_lexer_et/gherkin_lexer_et.c
401
+ - ext/gherkin_lexer_fa/gherkin_lexer_fa.c
414
402
  - ext/gherkin_lexer_fi/gherkin_lexer_fi.c
415
403
  - ext/gherkin_lexer_fr/gherkin_lexer_fr.c
416
404
  - ext/gherkin_lexer_he/gherkin_lexer_he.c
@@ -457,6 +445,7 @@ files:
457
445
  - ext/gherkin_lexer_eo/extconf.rb
458
446
  - ext/gherkin_lexer_es/extconf.rb
459
447
  - ext/gherkin_lexer_et/extconf.rb
448
+ - ext/gherkin_lexer_fa/extconf.rb
460
449
  - ext/gherkin_lexer_fi/extconf.rb
461
450
  - ext/gherkin_lexer_fr/extconf.rb
462
451
  - ext/gherkin_lexer_he/extconf.rb
@@ -510,7 +499,7 @@ rubyforge_project:
510
499
  rubygems_version: 1.8.24
511
500
  signing_key:
512
501
  specification_version: 3
513
- summary: gherkin-2.11.3
502
+ summary: gherkin-2.11.4
514
503
  test_files:
515
504
  - features/escaped_pipes.feature
516
505
  - features/feature_parser.feature
@@ -544,6 +533,7 @@ test_files:
544
533
  - spec/gherkin/fixtures/i18n_pt3.feature
545
534
  - spec/gherkin/fixtures/i18n_pt4.feature
546
535
  - spec/gherkin/fixtures/i18n_zh-CN.feature
536
+ - spec/gherkin/fixtures/iso-8859-1.feature
547
537
  - spec/gherkin/fixtures/issue_145.feature
548
538
  - spec/gherkin/fixtures/scenario_outline_with_tags.feature
549
539
  - spec/gherkin/fixtures/scenario_without_steps.feature
@@ -567,8 +557,8 @@ test_files:
567
557
  - spec/gherkin/output_stream_string_io.rb
568
558
  - spec/gherkin/parser/parser_spec.rb
569
559
  - spec/gherkin/sexp_recorder.rb
570
- - spec/gherkin/shared/bom_group.rb
571
560
  - spec/gherkin/shared/doc_string_group.rb
561
+ - spec/gherkin/shared/encoding_group.rb
572
562
  - spec/gherkin/shared/lexer_group.rb
573
563
  - spec/gherkin/shared/row_group.rb
574
564
  - spec/gherkin/shared/tags_group.rb
@@ -1,20 +0,0 @@
1
- #encoding: utf-8
2
- require 'spec_helper'
3
-
4
- module Gherkin
5
- module Lexer
6
- shared_examples_for "parsing windows files" do
7
- describe "with BOM" do
8
- it "should work just fine" do
9
- scan_file("with_bom.feature")
10
- @listener.to_sexp.should == [
11
- [:feature, "Feature", "Feature Text", "", 1],
12
- [:scenario, "Scenario", "Reading a Scenario", "", 2],
13
- [:step, "Given ", "there is a step", 3],
14
- [:eof]
15
- ]
16
- end
17
- end
18
- end
19
- end
20
- end