gherkin 1.0.26 → 1.0.27
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +6 -0
- data/Rakefile +2 -2
- data/VERSION.yml +1 -1
- data/features/escaped_pipes.feature +8 -0
- data/features/step_definitions/eyeball_steps.rb +3 -0
- data/lib/gherkin/formatter/escaping.rb +15 -0
- data/lib/gherkin/formatter/pretty_formatter.rb +3 -1
- data/lib/gherkin/i18n.rb +7 -7
- data/lib/gherkin/i18n.yml +13 -0
- data/ragel/lexer.c.rl.erb +4 -0
- data/ragel/lexer.java.rl.erb +2 -1
- data/ragel/lexer.rb.rl.erb +1 -1
- data/ragel/lexer_common.rl.erb +8 -5
- data/spec/gherkin/formatter/pretty_formatter_spec.rb +11 -2
- data/spec/gherkin/i18n_spec.rb +1 -0
- data/spec/gherkin/shared/row_spec.rb +5 -8
- data/tasks/ragel_task.rb +2 -4
- metadata +14 -21
data/History.txt
CHANGED
data/Rakefile
CHANGED
@@ -18,9 +18,9 @@ begin
|
|
18
18
|
gem.homepage = "http://github.com/aslakhellesoy/gherkin"
|
19
19
|
gem.authors = ["Mike Sassak", "Gregory Hnatiuk", "Aslak Hellesøy"]
|
20
20
|
gem.executables = ["gherkin"]
|
21
|
-
gem.add_dependency "trollop", ">= 1.
|
21
|
+
gem.add_dependency "trollop", ">= 1.16.2"
|
22
22
|
gem.add_development_dependency "rspec", ">= 1.3.0"
|
23
|
-
gem.add_development_dependency "cucumber", ">= 0.7.2"
|
23
|
+
# gem.add_development_dependency "cucumber", ">= 0.7.2"
|
24
24
|
gem.add_development_dependency "rake-compiler", ">= 0.7.0" unless defined?(JRUBY_VERSION)
|
25
25
|
|
26
26
|
gem.files -= FileList['ikvm/**/*']
|
data/VERSION.yml
CHANGED
@@ -0,0 +1,15 @@
|
|
1
|
+
module Gherkin
|
2
|
+
module Formatter
|
3
|
+
module Escaping
|
4
|
+
# Escapes a pipes and backslashes:
|
5
|
+
#
|
6
|
+
# * | becomes \|
|
7
|
+
# * \ becomes \\
|
8
|
+
#
|
9
|
+
# This is used in the pretty formatter.
|
10
|
+
def escape_cell(s)
|
11
|
+
s.gsub(/\|/, "\\|").gsub(/\\(?!\|)/, "\\\\\\\\")
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -3,6 +3,7 @@
|
|
3
3
|
require 'gherkin/formatter/colors'
|
4
4
|
require 'gherkin/formatter/monochrome_format'
|
5
5
|
require 'gherkin/formatter/argument'
|
6
|
+
require 'gherkin/formatter/escaping'
|
6
7
|
|
7
8
|
module Gherkin
|
8
9
|
module Formatter
|
@@ -11,6 +12,7 @@ module Gherkin
|
|
11
12
|
java_impl('gherkin.jar')
|
12
13
|
|
13
14
|
include Colors
|
15
|
+
include Escaping
|
14
16
|
|
15
17
|
def initialize(io, monochrome=false)
|
16
18
|
@io = io
|
@@ -67,7 +69,7 @@ module Gherkin
|
|
67
69
|
|
68
70
|
def row(row, line)
|
69
71
|
@rows ||= []
|
70
|
-
@rows << row
|
72
|
+
@rows << row.map{|cell| escape_cell(cell)}
|
71
73
|
end
|
72
74
|
|
73
75
|
def py_string(string, line)
|
data/lib/gherkin/i18n.rb
CHANGED
@@ -8,10 +8,10 @@ module Gherkin
|
|
8
8
|
java_impl('gherkin.jar')
|
9
9
|
end
|
10
10
|
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
LANGUAGES
|
11
|
+
FEATURE_ELEMENT_KEYS = %w{feature background scenario scenario_outline examples}
|
12
|
+
STEP_KEYWORD_KEYS = %w{given when then and but}
|
13
|
+
KEYWORD_KEYS = FEATURE_ELEMENT_KEYS + STEP_KEYWORD_KEYS
|
14
|
+
LANGUAGES = YAML.load_file(File.dirname(__FILE__) + '/i18n.yml')
|
15
15
|
|
16
16
|
class << self
|
17
17
|
include Rubify
|
@@ -141,7 +141,7 @@ module Gherkin
|
|
141
141
|
def keywords(iso_code)
|
142
142
|
iso_code = iso_code.to_s
|
143
143
|
raise "No #{iso_code.inspect} in #{@keywords.inspect}" if @keywords[iso_code].nil?
|
144
|
-
@keywords[iso_code].split('|').map{|keyword|
|
144
|
+
@keywords[iso_code].split('|').map{|keyword| real_keyword(iso_code, keyword)}
|
145
145
|
end
|
146
146
|
|
147
147
|
def keyword_table
|
@@ -167,9 +167,9 @@ module Gherkin
|
|
167
167
|
|
168
168
|
private
|
169
169
|
|
170
|
-
def
|
170
|
+
def real_keyword(iso_code, keyword)
|
171
171
|
if(STEP_KEYWORD_KEYS.index(iso_code))
|
172
|
-
(keyword + ' ').sub(/< $/,'')
|
172
|
+
(keyword + ' ').sub(/< $/, '')
|
173
173
|
else
|
174
174
|
keyword
|
175
175
|
end
|
data/lib/gherkin/i18n.yml
CHANGED
@@ -339,6 +339,19 @@
|
|
339
339
|
then: "*|Tada"
|
340
340
|
and: "*|Ir"
|
341
341
|
but: "*|Bet"
|
342
|
+
"lu":
|
343
|
+
name: Luxemburgish
|
344
|
+
native: Lëtzebuergesch
|
345
|
+
feature: Funktionalitéit
|
346
|
+
background: Hannergrond
|
347
|
+
scenario: Szenario
|
348
|
+
scenario_outline: Plang vum Szenario
|
349
|
+
examples: Beispiller
|
350
|
+
given: "*|ugeholl"
|
351
|
+
when: "*|wann"
|
352
|
+
then: "*|dann"
|
353
|
+
and: "*|an|a"
|
354
|
+
but: "*|awer|mä"
|
342
355
|
"lv":
|
343
356
|
name: Latvian
|
344
357
|
native: latviešu
|
data/ragel/lexer.c.rl.erb
CHANGED
@@ -181,6 +181,10 @@ static VALUE rb_eGherkinLexingError;
|
|
181
181
|
action store_cell_content {
|
182
182
|
VALUE con = ENCODED_STR_NEW(PTR_TO(content_start), LEN(content_start, p));
|
183
183
|
rb_funcall(con, rb_intern("strip!"), 0);
|
184
|
+
VALUE re_pipe = rb_reg_regcomp(rb_str_new2("\\\\\\|"));
|
185
|
+
VALUE re_backslash = rb_reg_regcomp(rb_str_new2("\\\\\\\\"));
|
186
|
+
rb_funcall(con, rb_intern("gsub!"), 2, re_pipe, rb_str_new2("|"));
|
187
|
+
rb_funcall(con, rb_intern("gsub!"), 2, re_backslash, rb_str_new2("\\"));
|
184
188
|
|
185
189
|
rb_ary_push(current_row, con);
|
186
190
|
}
|
data/ragel/lexer.java.rl.erb
CHANGED
@@ -114,7 +114,8 @@ public class <%= @i18n.underscored_iso_code.upcase %> implements Lexer {
|
|
114
114
|
}
|
115
115
|
|
116
116
|
action store_cell_content {
|
117
|
-
|
117
|
+
String con = substring(data, contentStart, p).trim();
|
118
|
+
currentRow.add(con.replaceAll("\\\\\\|", "|").replaceAll("\\\\\\\\", "\\\\"));
|
118
119
|
}
|
119
120
|
|
120
121
|
action store_row {
|
data/ragel/lexer.rb.rl.erb
CHANGED
data/ragel/lexer_common.rl.erb
CHANGED
@@ -11,6 +11,10 @@
|
|
11
11
|
|
12
12
|
EOF = '%_FEATURE_END_%'; # Explicit EOF added before scanning begins
|
13
13
|
EOL = ('\n' | '\r\n') @inc_line_number @last_newline;
|
14
|
+
BOM = 0xEF 0xBB 0xBF; # http://en.wikipedia.org/wiki/Byte_order_mark
|
15
|
+
|
16
|
+
PIPE = '|';
|
17
|
+
ESCAPED_PIPE = '\\|';
|
14
18
|
|
15
19
|
FeatureHeadingEnd = EOL+ space* (I18N_Background | I18N_Scenario | I18N_ScenarioOutline | '@' | '#' | EOF) >next_keyword_start;
|
16
20
|
ScenarioHeadingEnd = EOL+ space* ( I18N_Scenario | I18N_ScenarioOutline | I18N_Step | '@' | '#' | EOF ) >next_keyword_start;
|
@@ -30,16 +34,15 @@
|
|
30
34
|
Tag = ( ('@' [^@\r\n\t ]+) >begin_content ) %store_tag_content;
|
31
35
|
Tags = space* (Tag space*)+ EOL+;
|
32
36
|
|
33
|
-
StartRow = space*
|
34
|
-
EndRow = EOL space* ^
|
35
|
-
Cell =
|
36
|
-
RowBody = space* Cell
|
37
|
+
StartRow = space* PIPE >start_row;
|
38
|
+
EndRow = EOL space* ^PIPE >next_keyword_start;
|
39
|
+
Cell = PIPE (ESCAPED_PIPE | (any - PIPE)+ )* >begin_cell_content %store_cell_content;
|
40
|
+
RowBody = space* Cell** PIPE :>> (space* EOL+ space*) %store_row;
|
37
41
|
Row = StartRow :>> RowBody <: EndRow?;
|
38
42
|
|
39
43
|
StartPyString = '"""' >start_pystring space* :>> EOL;
|
40
44
|
EndPyString = (space* '"""') >next_keyword_start;
|
41
45
|
PyString = space* StartPyString %begin_pystring_content (^EOL | EOL)* :>> EndPyString %store_pystring_content space* EOL+;
|
42
|
-
BOM = 0xEF 0xBB 0xBF; # http://en.wikipedia.org/wiki/Byte_order_mark
|
43
46
|
|
44
47
|
Tokens = BOM? (space | EOL)* (Tags | Comment | FeatureHeading | BackgroundHeading | ScenarioHeading | ScenarioOutlineHeading | ExamplesHeading | Step | Row | PyString)* (space | EOL)* EOF;
|
45
48
|
|
@@ -112,8 +112,8 @@ module Gherkin
|
|
112
112
|
pystrings
|
113
113
|
"""
|
114
114
|
And there is another step
|
115
|
-
| æ
|
116
|
-
| a |
|
115
|
+
| æ | \\|o |
|
116
|
+
| \\|a | ø\\\\ |
|
117
117
|
Then we will see steps
|
118
118
|
})
|
119
119
|
end
|
@@ -148,6 +148,15 @@ Feature: Feature Description
|
|
148
148
|
it "should preserve tabs" do
|
149
149
|
assert_pretty(IO.read(File.dirname(__FILE__) + '/tabs.feature'), IO.read(File.dirname(__FILE__) + '/spaces.feature'))
|
150
150
|
end
|
151
|
+
|
152
|
+
it "should escape backslashes and pipes" do
|
153
|
+
io = StringIO.new
|
154
|
+
l = PrettyFormatter.new(io, true)
|
155
|
+
l.row(['|', '\\'], 1)
|
156
|
+
l.flush_table
|
157
|
+
io.rewind
|
158
|
+
io.read.should == ' | \\| | \\\\ |' + "\n"
|
159
|
+
end
|
151
160
|
end
|
152
161
|
end
|
153
162
|
end
|
data/spec/gherkin/i18n_spec.rb
CHANGED
@@ -25,6 +25,11 @@ module Gherkin
|
|
25
25
|
@listener.should_receive(:row).with(r(%w{foo bar}), 1)
|
26
26
|
@lexer.scan("| foo | bar |\n")
|
27
27
|
end
|
28
|
+
|
29
|
+
it "should escape backslashed pipes" do
|
30
|
+
@listener.should_receive(:row).with(r(['|', 'the', '\a', '\\', '|\\|']), 1)
|
31
|
+
@lexer.scan('| \| | the | \a | \\ | \|\\\| |' + "\n")
|
32
|
+
end
|
28
33
|
|
29
34
|
it "should parse cells with spaces within the content" do
|
30
35
|
@listener.should_receive(:row).with(r(["Dill pickle", "Valencia orange"]), 1)
|
@@ -32,14 +37,6 @@ module Gherkin
|
|
32
37
|
end
|
33
38
|
|
34
39
|
it "should allow utf-8" do
|
35
|
-
# Fails in 1.9.1!
|
36
|
-
# 'Gherkin::Lexer::Table should allow utf-8 with using == to evaluate' FAILED
|
37
|
-
# expected: [[:row, [["ůﻚ", "2"]], 1]],
|
38
|
-
# got: [[:row, [["\xC5\xAF\xEF\xBB\x9A", "2"]], 1]] (using ==)
|
39
|
-
# BUT, simply running:
|
40
|
-
# [[:row, [["ůﻚ", "2"]], 1]].should == [[:row, [["\xC5\xAF\xEF\xBB\x9A", "2"]], 1]]
|
41
|
-
# passes
|
42
|
-
#
|
43
40
|
@lexer.scan(" | ůﻚ | 2 | \n")
|
44
41
|
@listener.to_sexp.should == [
|
45
42
|
[:row, ["ůﻚ", "2"], 1],
|
data/tasks/ragel_task.rb
CHANGED
@@ -29,8 +29,7 @@ class RagelTask
|
|
29
29
|
{
|
30
30
|
'c' => "ext/gherkin_lexer_#{@i18n.underscored_iso_code}/gherkin_lexer_#{@i18n.underscored_iso_code}.c",
|
31
31
|
'java' => "java/src/main/java/gherkin/lexer/#{@i18n.underscored_iso_code.upcase}.java",
|
32
|
-
'rb' => "lib/gherkin/rb_lexer/#{@i18n.underscored_iso_code}.rb"
|
33
|
-
'csharp' => "tmp/#{@i18n.underscored_iso_code}.cs"
|
32
|
+
'rb' => "lib/gherkin/rb_lexer/#{@i18n.underscored_iso_code}.rb"
|
34
33
|
}[@lang]
|
35
34
|
end
|
36
35
|
|
@@ -54,8 +53,7 @@ class RagelTask
|
|
54
53
|
{
|
55
54
|
'c' => '-C',
|
56
55
|
'java' => '-J',
|
57
|
-
'rb' => '-R'
|
58
|
-
'csharp' => '-A -L -T0'
|
56
|
+
'rb' => '-R'
|
59
57
|
}[@lang]
|
60
58
|
end
|
61
59
|
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 1
|
7
7
|
- 0
|
8
|
-
-
|
9
|
-
version: 1.0.
|
8
|
+
- 27
|
9
|
+
version: 1.0.27
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Mike Sassak
|
@@ -16,7 +16,7 @@ autorequire:
|
|
16
16
|
bindir: bin
|
17
17
|
cert_chain: []
|
18
18
|
|
19
|
-
date: 2010-05-
|
19
|
+
date: 2010-05-18 00:00:00 +02:00
|
20
20
|
default_executable: gherkin
|
21
21
|
dependencies:
|
22
22
|
- !ruby/object:Gem::Dependency
|
@@ -28,8 +28,9 @@ dependencies:
|
|
28
28
|
- !ruby/object:Gem::Version
|
29
29
|
segments:
|
30
30
|
- 1
|
31
|
-
-
|
32
|
-
|
31
|
+
- 16
|
32
|
+
- 2
|
33
|
+
version: 1.16.2
|
33
34
|
type: :runtime
|
34
35
|
version_requirements: *id001
|
35
36
|
- !ruby/object:Gem::Dependency
|
@@ -46,24 +47,10 @@ dependencies:
|
|
46
47
|
version: 1.3.0
|
47
48
|
type: :development
|
48
49
|
version_requirements: *id002
|
49
|
-
- !ruby/object:Gem::Dependency
|
50
|
-
name: cucumber
|
51
|
-
prerelease: false
|
52
|
-
requirement: &id003 !ruby/object:Gem::Requirement
|
53
|
-
requirements:
|
54
|
-
- - ">="
|
55
|
-
- !ruby/object:Gem::Version
|
56
|
-
segments:
|
57
|
-
- 0
|
58
|
-
- 7
|
59
|
-
- 2
|
60
|
-
version: 0.7.2
|
61
|
-
type: :development
|
62
|
-
version_requirements: *id003
|
63
50
|
- !ruby/object:Gem::Dependency
|
64
51
|
name: rake-compiler
|
65
52
|
prerelease: false
|
66
|
-
requirement: &
|
53
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
67
54
|
requirements:
|
68
55
|
- - ">="
|
69
56
|
- !ruby/object:Gem::Version
|
@@ -73,7 +60,7 @@ dependencies:
|
|
73
60
|
- 0
|
74
61
|
version: 0.7.0
|
75
62
|
type: :development
|
76
|
-
version_requirements: *
|
63
|
+
version_requirements: *id003
|
77
64
|
description: A fast Gherkin lexer/parser based on the Ragel State Machine Compiler.
|
78
65
|
email: cukes@googlegroups.com
|
79
66
|
executables:
|
@@ -104,6 +91,7 @@ extensions:
|
|
104
91
|
- ext/gherkin_lexer_ja/extconf.rb
|
105
92
|
- ext/gherkin_lexer_ko/extconf.rb
|
106
93
|
- ext/gherkin_lexer_lt/extconf.rb
|
94
|
+
- ext/gherkin_lexer_lu/extconf.rb
|
107
95
|
- ext/gherkin_lexer_lv/extconf.rb
|
108
96
|
- ext/gherkin_lexer_nl/extconf.rb
|
109
97
|
- ext/gherkin_lexer_no/extconf.rb
|
@@ -161,6 +149,7 @@ files:
|
|
161
149
|
- ext/gherkin_lexer_ja/gherkin_lexer_ja.c
|
162
150
|
- ext/gherkin_lexer_ko/gherkin_lexer_ko.c
|
163
151
|
- ext/gherkin_lexer_lt/gherkin_lexer_lt.c
|
152
|
+
- ext/gherkin_lexer_lu/gherkin_lexer_lu.c
|
164
153
|
- ext/gherkin_lexer_lv/gherkin_lexer_lv.c
|
165
154
|
- ext/gherkin_lexer_nl/gherkin_lexer_nl.c
|
166
155
|
- ext/gherkin_lexer_no/gherkin_lexer_no.c
|
@@ -179,10 +168,12 @@ files:
|
|
179
168
|
- ext/gherkin_lexer_vi/gherkin_lexer_vi.c
|
180
169
|
- ext/gherkin_lexer_zh_cn/gherkin_lexer_zh_cn.c
|
181
170
|
- ext/gherkin_lexer_zh_tw/gherkin_lexer_zh_tw.c
|
171
|
+
- features/escaped_pipes.feature
|
182
172
|
- features/feature_parser.feature
|
183
173
|
- features/native_lexer.feature
|
184
174
|
- features/parser_with_native_lexer.feature
|
185
175
|
- features/pretty_printer.feature
|
176
|
+
- features/step_definitions/eyeball_steps.rb
|
186
177
|
- features/step_definitions/gherkin_steps.rb
|
187
178
|
- features/step_definitions/pretty_formatter_steps.rb
|
188
179
|
- features/steps_parser.feature
|
@@ -197,6 +188,7 @@ files:
|
|
197
188
|
- lib/gherkin/cli/main.rb
|
198
189
|
- lib/gherkin/formatter/argument.rb
|
199
190
|
- lib/gherkin/formatter/colors.rb
|
191
|
+
- lib/gherkin/formatter/escaping.rb
|
200
192
|
- lib/gherkin/formatter/monochrome_format.rb
|
201
193
|
- lib/gherkin/formatter/pretty_formatter.rb
|
202
194
|
- lib/gherkin/i18n.rb
|
@@ -238,6 +230,7 @@ files:
|
|
238
230
|
- lib/gherkin/rb_lexer/ja.rb
|
239
231
|
- lib/gherkin/rb_lexer/ko.rb
|
240
232
|
- lib/gherkin/rb_lexer/lt.rb
|
233
|
+
- lib/gherkin/rb_lexer/lu.rb
|
241
234
|
- lib/gherkin/rb_lexer/lv.rb
|
242
235
|
- lib/gherkin/rb_lexer/nl.rb
|
243
236
|
- lib/gherkin/rb_lexer/no.rb
|