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 +2 -3
- data/README.rdoc +19 -0
- data/Rakefile +16 -15
- data/VERSION.yml +1 -1
- data/bin/gherkin +2 -2
- data/features/pretty_printer.feature +5 -2
- data/features/step_definitions/pretty_printer_steps.rb +6 -1
- data/gherkin.gemspec +60 -17
- data/lib/.gitignore +4 -2
- data/lib/gherkin/c_lexer.rb +3 -3
- data/lib/gherkin/core_ext/array.rb +5 -0
- data/lib/gherkin/lexer.rb +6 -5
- data/lib/gherkin/rb_lexer.rb +3 -2
- data/lib/gherkin/tools/pretty_printer.rb +10 -4
- data/nativegems.sh +5 -0
- data/ragel/lexer.c.rl.erb +28 -12
- data/ragel/lexer.java.rl.erb +5 -3
- data/ragel/lexer.rb.rl.erb +14 -15
- data/ragel/lexer_common.rl.erb +6 -6
- data/spec/gherkin/fixtures/1.feature +8 -0
- data/spec/gherkin/fixtures/complex.feature +2 -2
- data/spec/gherkin/shared/lexer_spec.rb +17 -4
- data/spec/gherkin/shared/py_string_spec.rb +12 -0
- data/tasks/bench.rake +28 -11
- data/tasks/compile.rake +70 -0
- data/tasks/ragel_task.rb +83 -0
- metadata +105 -16
- data/ext/gherkin_lexer/.gitignore +0 -6
- data/ext/gherkin_lexer/extconf.rb +0 -6
- data/tasks/ext.rake +0 -49
- data/tasks/ragel.rake +0 -94
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
|
+
version: 0.0.4
|
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-
|
14
|
+
date: 2009-11-28 00:00:00 +01:00
|
15
15
|
default_executable: gherkin
|
16
16
|
dependencies:
|
17
17
|
- !ruby/object:Gem::Dependency
|
@@ -30,16 +30,65 @@ dependencies:
|
|
30
30
|
version_requirement:
|
31
31
|
version_requirements: !ruby/object:Gem::Requirement
|
32
32
|
requirements:
|
33
|
-
- - "
|
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
|
+
- - "="
|
34
44
|
- !ruby/object:Gem::Version
|
35
|
-
version:
|
45
|
+
version: 0.6.0
|
36
46
|
version:
|
37
47
|
description: A fast Gherkin lexer in Ragel
|
38
48
|
email: cukes@googlegroups.com
|
39
49
|
executables:
|
40
50
|
- gherkin
|
41
51
|
extensions:
|
42
|
-
- ext/
|
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
|
43
92
|
extra_rdoc_files:
|
44
93
|
- LICENSE
|
45
94
|
- README.rdoc
|
@@ -51,9 +100,46 @@ files:
|
|
51
100
|
- VERSION.yml
|
52
101
|
- bin/gherkin
|
53
102
|
- cucumber.yml
|
54
|
-
- ext/
|
55
|
-
- ext/
|
56
|
-
- ext/
|
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
|
57
143
|
- features/feature_parser.feature
|
58
144
|
- features/native_lexer.feature
|
59
145
|
- features/parser_with_native_lexer.feature
|
@@ -77,6 +163,7 @@ files:
|
|
77
163
|
- lib/.gitignore
|
78
164
|
- lib/gherkin.rb
|
79
165
|
- lib/gherkin/c_lexer.rb
|
166
|
+
- lib/gherkin/core_ext/array.rb
|
80
167
|
- lib/gherkin/i18n.yml
|
81
168
|
- lib/gherkin/i18n_lexer.rb
|
82
169
|
- lib/gherkin/java_lexer.rb
|
@@ -95,10 +182,10 @@ files:
|
|
95
182
|
- lib/gherkin/rb_lexer/cy.rb
|
96
183
|
- lib/gherkin/rb_lexer/da.rb
|
97
184
|
- lib/gherkin/rb_lexer/de.rb
|
98
|
-
- lib/gherkin/rb_lexer/en-au.rb
|
99
|
-
- lib/gherkin/rb_lexer/en-lol.rb
|
100
|
-
- lib/gherkin/rb_lexer/en-tx.rb
|
101
185
|
- lib/gherkin/rb_lexer/en.rb
|
186
|
+
- lib/gherkin/rb_lexer/enau.rb
|
187
|
+
- lib/gherkin/rb_lexer/enlol.rb
|
188
|
+
- lib/gherkin/rb_lexer/entx.rb
|
102
189
|
- lib/gherkin/rb_lexer/es.rb
|
103
190
|
- lib/gherkin/rb_lexer/et.rb
|
104
191
|
- lib/gherkin/rb_lexer/fi.rb
|
@@ -121,21 +208,23 @@ files:
|
|
121
208
|
- lib/gherkin/rb_lexer/ru.rb
|
122
209
|
- lib/gherkin/rb_lexer/se.rb
|
123
210
|
- lib/gherkin/rb_lexer/sk.rb
|
124
|
-
- lib/gherkin/rb_lexer/sr-Latn.rb
|
125
211
|
- lib/gherkin/rb_lexer/sr.rb
|
212
|
+
- lib/gherkin/rb_lexer/srLatn.rb
|
126
213
|
- lib/gherkin/rb_lexer/tr.rb
|
127
214
|
- lib/gherkin/rb_lexer/uz.rb
|
128
215
|
- lib/gherkin/rb_lexer/vi.rb
|
129
|
-
- lib/gherkin/rb_lexer/
|
130
|
-
- lib/gherkin/rb_lexer/
|
216
|
+
- lib/gherkin/rb_lexer/zhCN.rb
|
217
|
+
- lib/gherkin/rb_lexer/zhTW.rb
|
131
218
|
- lib/gherkin/rb_parser.rb
|
132
219
|
- lib/gherkin/tools/pretty_printer.rb
|
220
|
+
- nativegems.sh
|
133
221
|
- ragel/i18n/.gitignore
|
134
222
|
- ragel/lexer.c.rl.erb
|
135
223
|
- ragel/lexer.java.rl.erb
|
136
224
|
- ragel/lexer.rb.rl.erb
|
137
225
|
- ragel/lexer_common.rl.erb
|
138
226
|
- spec/gherkin/c_lexer_spec.rb
|
227
|
+
- spec/gherkin/fixtures/1.feature
|
139
228
|
- spec/gherkin/fixtures/complex.feature
|
140
229
|
- spec/gherkin/fixtures/i18n_fr.feature
|
141
230
|
- spec/gherkin/fixtures/i18n_no.feature
|
@@ -157,9 +246,9 @@ files:
|
|
157
246
|
- tasks/bench/feature_builder.rb
|
158
247
|
- tasks/bench/generated/.gitignore
|
159
248
|
- tasks/bench/null_listener.rb
|
249
|
+
- tasks/compile.rake
|
160
250
|
- tasks/cucumber.rake
|
161
|
-
- tasks/
|
162
|
-
- tasks/ragel.rake
|
251
|
+
- tasks/ragel_task.rb
|
163
252
|
- tasks/rdoc.rake
|
164
253
|
- tasks/rspec.rake
|
165
254
|
has_rdoc: true
|
data/tasks/ext.rake
DELETED
@@ -1,49 +0,0 @@
|
|
1
|
-
CLEAN.include [
|
2
|
-
'**/*.{o,bundle,jar,so,obj,pdb,lib,def,exp,log}', 'ext/*/Makefile', 'ext/*/conftest.dSYM',
|
3
|
-
'java/target'
|
4
|
-
]
|
5
|
-
|
6
|
-
if(defined?(JRUBY_VERSION))
|
7
|
-
|
8
|
-
def ext_task(name)
|
9
|
-
desc "Compile the Native Java extensions"
|
10
|
-
task :compile => ['ragel:java'] do
|
11
|
-
sh("ant -f java/build.xml")
|
12
|
-
end
|
13
|
-
end
|
14
|
-
|
15
|
-
else # NOT JRUBY
|
16
|
-
|
17
|
-
def ext_task(name)
|
18
|
-
ext_dir = "ext/#{name}"
|
19
|
-
ext_bundle = "#{ext_dir}/#{name}.#{Config::CONFIG['DLEXT']}"
|
20
|
-
ext_files = FileList[
|
21
|
-
"#{ext_dir}/*.c",
|
22
|
-
"#{ext_dir}/*.h",
|
23
|
-
"#{ext_dir}/*.rl",
|
24
|
-
"#{ext_dir}/extconf.rb",
|
25
|
-
"#{ext_dir}/Makefile",
|
26
|
-
"lib"
|
27
|
-
]
|
28
|
-
|
29
|
-
task "compile:#{name}" => ["#{ext_dir}/Makefile", ext_bundle]
|
30
|
-
|
31
|
-
desc "Compile the Native C extensions"
|
32
|
-
task :compile => ['ragel:c', "compile:#{name}"]
|
33
|
-
|
34
|
-
file "#{ext_dir}/Makefile" => ["#{ext_dir}/extconf.rb"] do
|
35
|
-
cd(ext_dir) { ruby "extconf.rb" }
|
36
|
-
end
|
37
|
-
|
38
|
-
file ext_bundle => ext_files do
|
39
|
-
cd ext_dir do
|
40
|
-
sh(WINDOWS ? 'nmake' : 'make')
|
41
|
-
end
|
42
|
-
cp ext_bundle, 'lib/'
|
43
|
-
end
|
44
|
-
end
|
45
|
-
end
|
46
|
-
|
47
|
-
ext_task :gherkin_lexer
|
48
|
-
|
49
|
-
task :package => :compile
|
data/tasks/ragel.rake
DELETED
@@ -1,94 +0,0 @@
|
|
1
|
-
CLEAN.include [
|
2
|
-
'ragel/i18n/*.rl',
|
3
|
-
'lib/gherkin/rb_lexer/*.rb',
|
4
|
-
'ext/gherkin_lexer/*.c',
|
5
|
-
'java/src/gherkin/lexer/*.java',
|
6
|
-
]
|
7
|
-
|
8
|
-
class RagelCompiler
|
9
|
-
RL_OUTPUT_DIR = File.dirname(__FILE__) + "/../ragel/i18n"
|
10
|
-
|
11
|
-
def initialize(target)
|
12
|
-
require 'yaml'
|
13
|
-
require 'erb'
|
14
|
-
|
15
|
-
@target = target
|
16
|
-
@flag, @output_dir, @filename_proc = case
|
17
|
-
when @target == "rb" then ["-R", "lib/gherkin/rb_lexer", lambda{|name| name}]
|
18
|
-
when @target == "c" then ["-C", "ext/gherkin_lexer", lambda{|name| name}]
|
19
|
-
when @target == "java" then ["-J", "java/src/gherkin/lexer", lambda{|name| name.gsub(/[\s-]/, '').capitalize}]
|
20
|
-
end
|
21
|
-
|
22
|
-
@i18n_languages = YAML.load_file(File.dirname(__FILE__) + '/../lib/gherkin/i18n.yml')
|
23
|
-
@common_tmpl = ERB.new(IO.read(File.dirname(__FILE__) + '/../ragel/lexer_common.rl.erb'))
|
24
|
-
@actions_tmpl = ERB.new(IO.read(File.dirname(__FILE__) + "/../ragel/lexer.#{@target}.rl.erb"))
|
25
|
-
end
|
26
|
-
|
27
|
-
def compile_all
|
28
|
-
@i18n_languages.keys.each do |lang|
|
29
|
-
compile(lang)
|
30
|
-
end
|
31
|
-
end
|
32
|
-
|
33
|
-
def compile(i18n_language)
|
34
|
-
FileUtils.mkdir(RL_OUTPUT_DIR) unless File.exist?(RL_OUTPUT_DIR)
|
35
|
-
|
36
|
-
common_path = RL_OUTPUT_DIR + "/lexer_common.#{i18n_language}.rl"
|
37
|
-
actions_path = RL_OUTPUT_DIR + "/#{i18n_language}.#{@target}.rl"
|
38
|
-
|
39
|
-
generate_common(i18n_language, common_path)
|
40
|
-
generate_actions(i18n_language, actions_path)
|
41
|
-
|
42
|
-
sh "ragel #{@flag} #{actions_path} -o #{@output_dir}/#{@filename_proc.call(i18n_language)}.#{@target}"
|
43
|
-
end
|
44
|
-
|
45
|
-
def generate_common(i18n_language, path)
|
46
|
-
i18n = prep_keywords(@i18n_languages['en'].merge(@i18n_languages[i18n_language]))
|
47
|
-
common = @common_tmpl.result(binding)
|
48
|
-
write common, path
|
49
|
-
end
|
50
|
-
|
51
|
-
def generate_actions(i18n_language, path)
|
52
|
-
i18n_lexer_class_name = i18n_language.gsub(/[\s-]/, '').capitalize
|
53
|
-
impl = @actions_tmpl.result(binding)
|
54
|
-
write impl, path
|
55
|
-
end
|
56
|
-
|
57
|
-
def prep_keywords(i18n)
|
58
|
-
delimited_keywords = %w{feature background scenario scenario_outline examples}
|
59
|
-
bare_keywords = %w{given when then and but}
|
60
|
-
all_keywords = delimited_keywords + bare_keywords
|
61
|
-
|
62
|
-
all_keywords.each { |kw| i18n[kw] = i18n[kw].split("|") }
|
63
|
-
delimited_keywords.each { |kw| i18n[kw].map! { |v| v += ':'} }
|
64
|
-
bare_keywords.each { |kw| i18n[kw].map! { |v| (v + ' ').sub(/< $/,'')} }
|
65
|
-
all_keywords.each { |kw| i18n[kw] = '("' + i18n[kw].join('" | "') + '")' }
|
66
|
-
i18n
|
67
|
-
end
|
68
|
-
|
69
|
-
def write(content, filename)
|
70
|
-
File.open(filename, "wb") do |file|
|
71
|
-
file.write(content)
|
72
|
-
end
|
73
|
-
end
|
74
|
-
end
|
75
|
-
|
76
|
-
namespace :ragel do
|
77
|
-
desc "Generate i18n sources for C lexers (TODO: Do it for all)"
|
78
|
-
task :c do
|
79
|
-
RagelCompiler.new("c").compile('en')
|
80
|
-
end
|
81
|
-
|
82
|
-
desc "Generate all i18n Ruby lexers"
|
83
|
-
task :rb do
|
84
|
-
RagelCompiler.new("rb").compile_all
|
85
|
-
end
|
86
|
-
|
87
|
-
desc "Generate all i18n Java lexers"
|
88
|
-
task :java do
|
89
|
-
RagelCompiler.new("java").compile_all
|
90
|
-
end
|
91
|
-
end
|
92
|
-
|
93
|
-
desc "Generate all i18n lexers for all programming languages"
|
94
|
-
task :ragel => ['ragel:c', 'ragel:rb', 'ragel:java']
|