gherkin 2.12.2 → 3.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +2 -15
- data/CONTRIBUTING.md +23 -0
- data/Gemfile +0 -3
- data/LICENSE +18 -17
- data/Makefile +65 -0
- data/README.md +9 -268
- data/Rakefile +17 -19
- data/bin/gherkin-generate-ast +21 -0
- data/bin/gherkin-generate-pickles +25 -0
- data/bin/gherkin-generate-tokens +12 -0
- data/gherkin-ruby.razor +218 -0
- data/gherkin.gemspec +22 -76
- data/lib/gherkin/ast_builder.rb +243 -0
- data/lib/gherkin/ast_node.rb +30 -0
- data/lib/gherkin/dialect.rb +58 -0
- data/lib/gherkin/errors.rb +45 -0
- data/lib/gherkin/gherkin-languages.json +2968 -0
- data/lib/gherkin/gherkin_line.rb +95 -0
- data/lib/gherkin/parser.rb +1910 -0
- data/lib/gherkin/pickles/compiler.rb +164 -0
- data/lib/gherkin/token.rb +18 -0
- data/lib/gherkin/token_formatter_builder.rb +39 -0
- data/lib/gherkin/token_matcher.rb +169 -0
- data/lib/gherkin/token_scanner.rb +40 -0
- data/spec/capture_warnings.rb +68 -0
- data/spec/coverage.rb +10 -0
- data/spec/gherkin/parser_spec.rb +146 -0
- metadata +60 -567
- data/.gitattributes +0 -2
- data/.mailmap +0 -2
- data/.rbenv-gemsets +0 -1
- data/.rspec +0 -1
- data/.ruby-gemset +0 -1
- data/.ruby-version +0 -1
- data/.yardopts +0 -5
- data/History.md +0 -881
- data/build_native_gems.sh +0 -7
- data/cucumber.yml +0 -5
- data/examples/parse_and_output_json.rb +0 -19
- data/ext/gherkin_lexer_ar/extconf.rb +0 -6
- data/ext/gherkin_lexer_ar/gherkin_lexer_ar.c +0 -1432
- data/ext/gherkin_lexer_bg/extconf.rb +0 -6
- data/ext/gherkin_lexer_bg/gherkin_lexer_bg.c +0 -1655
- data/ext/gherkin_lexer_bm/extconf.rb +0 -6
- data/ext/gherkin_lexer_bm/gherkin_lexer_bm.c +0 -1516
- data/ext/gherkin_lexer_ca/extconf.rb +0 -6
- data/ext/gherkin_lexer_ca/gherkin_lexer_ca.c +0 -1581
- data/ext/gherkin_lexer_cs/extconf.rb +0 -6
- data/ext/gherkin_lexer_cs/gherkin_lexer_cs.c +0 -1515
- data/ext/gherkin_lexer_cy_gb/extconf.rb +0 -6
- data/ext/gherkin_lexer_cy_gb/gherkin_lexer_cy_gb.c +0 -1282
- data/ext/gherkin_lexer_da/extconf.rb +0 -6
- data/ext/gherkin_lexer_da/gherkin_lexer_da.c +0 -1298
- data/ext/gherkin_lexer_de/extconf.rb +0 -6
- data/ext/gherkin_lexer_de/gherkin_lexer_de.c +0 -1425
- data/ext/gherkin_lexer_el/extconf.rb +0 -6
- data/ext/gherkin_lexer_el/gherkin_lexer_el.c +0 -1919
- data/ext/gherkin_lexer_en/extconf.rb +0 -6
- data/ext/gherkin_lexer_en/gherkin_lexer_en.c +0 -1418
- data/ext/gherkin_lexer_en_au/extconf.rb +0 -6
- data/ext/gherkin_lexer_en_au/gherkin_lexer_en_au.c +0 -1765
- data/ext/gherkin_lexer_en_lol/extconf.rb +0 -6
- data/ext/gherkin_lexer_en_lol/gherkin_lexer_en_lol.c +0 -1177
- data/ext/gherkin_lexer_en_old/extconf.rb +0 -6
- data/ext/gherkin_lexer_en_old/gherkin_lexer_en_old.c +0 -1309
- data/ext/gherkin_lexer_en_pirate/extconf.rb +0 -6
- data/ext/gherkin_lexer_en_pirate/gherkin_lexer_en_pirate.c +0 -1471
- data/ext/gherkin_lexer_en_scouse/extconf.rb +0 -6
- data/ext/gherkin_lexer_en_scouse/gherkin_lexer_en_scouse.c +0 -1634
- data/ext/gherkin_lexer_en_tx/extconf.rb +0 -6
- data/ext/gherkin_lexer_en_tx/gherkin_lexer_en_tx.c +0 -1265
- data/ext/gherkin_lexer_eo/extconf.rb +0 -6
- data/ext/gherkin_lexer_eo/gherkin_lexer_eo.c +0 -1241
- data/ext/gherkin_lexer_es/extconf.rb +0 -6
- data/ext/gherkin_lexer_es/gherkin_lexer_es.c +0 -1399
- data/ext/gherkin_lexer_et/extconf.rb +0 -6
- data/ext/gherkin_lexer_et/gherkin_lexer_et.c +0 -1236
- data/ext/gherkin_lexer_fa/extconf.rb +0 -6
- data/ext/gherkin_lexer_fa/gherkin_lexer_fa.c +0 -1475
- data/ext/gherkin_lexer_fi/extconf.rb +0 -6
- data/ext/gherkin_lexer_fi/gherkin_lexer_fi.c +0 -1215
- data/ext/gherkin_lexer_fr/extconf.rb +0 -6
- data/ext/gherkin_lexer_fr/gherkin_lexer_fr.c +0 -1493
- data/ext/gherkin_lexer_gl/extconf.rb +0 -6
- data/ext/gherkin_lexer_gl/gherkin_lexer_gl.c +0 -1374
- data/ext/gherkin_lexer_he/extconf.rb +0 -6
- data/ext/gherkin_lexer_he/gherkin_lexer_he.c +0 -1374
- data/ext/gherkin_lexer_hi/extconf.rb +0 -6
- data/ext/gherkin_lexer_hi/gherkin_lexer_hi.c +0 -1848
- data/ext/gherkin_lexer_hr/extconf.rb +0 -6
- data/ext/gherkin_lexer_hr/gherkin_lexer_hr.c +0 -1323
- data/ext/gherkin_lexer_hu/extconf.rb +0 -6
- data/ext/gherkin_lexer_hu/gherkin_lexer_hu.c +0 -1376
- data/ext/gherkin_lexer_id/extconf.rb +0 -6
- data/ext/gherkin_lexer_id/gherkin_lexer_id.c +0 -1208
- data/ext/gherkin_lexer_is/extconf.rb +0 -6
- data/ext/gherkin_lexer_is/gherkin_lexer_is.c +0 -1376
- data/ext/gherkin_lexer_it/extconf.rb +0 -6
- data/ext/gherkin_lexer_it/gherkin_lexer_it.c +0 -1340
- data/ext/gherkin_lexer_ja/extconf.rb +0 -6
- data/ext/gherkin_lexer_ja/gherkin_lexer_ja.c +0 -1699
- data/ext/gherkin_lexer_kn/extconf.rb +0 -6
- data/ext/gherkin_lexer_kn/gherkin_lexer_kn.c +0 -1965
- data/ext/gherkin_lexer_ko/extconf.rb +0 -6
- data/ext/gherkin_lexer_ko/gherkin_lexer_ko.c +0 -1360
- data/ext/gherkin_lexer_lt/extconf.rb +0 -6
- data/ext/gherkin_lexer_lt/gherkin_lexer_lt.c +0 -1296
- data/ext/gherkin_lexer_lu/extconf.rb +0 -6
- data/ext/gherkin_lexer_lu/gherkin_lexer_lu.c +0 -1389
- data/ext/gherkin_lexer_lv/extconf.rb +0 -6
- data/ext/gherkin_lexer_lv/gherkin_lexer_lv.c +0 -1425
- data/ext/gherkin_lexer_nl/extconf.rb +0 -6
- data/ext/gherkin_lexer_nl/gherkin_lexer_nl.c +0 -1368
- data/ext/gherkin_lexer_no/extconf.rb +0 -6
- data/ext/gherkin_lexer_no/gherkin_lexer_no.c +0 -1311
- data/ext/gherkin_lexer_pa/extconf.rb +0 -6
- data/ext/gherkin_lexer_pa/gherkin_lexer_pa.c +0 -2160
- data/ext/gherkin_lexer_pl/extconf.rb +0 -6
- data/ext/gherkin_lexer_pl/gherkin_lexer_pl.c +0 -1738
- data/ext/gherkin_lexer_pt/extconf.rb +0 -6
- data/ext/gherkin_lexer_pt/gherkin_lexer_pt.c +0 -1711
- data/ext/gherkin_lexer_ro/extconf.rb +0 -6
- data/ext/gherkin_lexer_ro/gherkin_lexer_ro.c +0 -1427
- data/ext/gherkin_lexer_ru/extconf.rb +0 -6
- data/ext/gherkin_lexer_ru/gherkin_lexer_ru.c +0 -2071
- data/ext/gherkin_lexer_sk/extconf.rb +0 -6
- data/ext/gherkin_lexer_sk/gherkin_lexer_sk.c +0 -1739
- data/ext/gherkin_lexer_sr_cyrl/extconf.rb +0 -6
- data/ext/gherkin_lexer_sr_cyrl/gherkin_lexer_sr_cyrl.c +0 -2112
- data/ext/gherkin_lexer_sr_latn/extconf.rb +0 -6
- data/ext/gherkin_lexer_sr_latn/gherkin_lexer_sr_latn.c +0 -1567
- data/ext/gherkin_lexer_sv/extconf.rb +0 -6
- data/ext/gherkin_lexer_sv/gherkin_lexer_sv.c +0 -1324
- data/ext/gherkin_lexer_th/extconf.rb +0 -6
- data/ext/gherkin_lexer_th/gherkin_lexer_th.c +0 -2840
- data/ext/gherkin_lexer_tl/extconf.rb +0 -6
- data/ext/gherkin_lexer_tl/gherkin_lexer_tl.c +0 -2021
- data/ext/gherkin_lexer_tr/extconf.rb +0 -6
- data/ext/gherkin_lexer_tr/gherkin_lexer_tr.c +0 -1347
- data/ext/gherkin_lexer_tt/extconf.rb +0 -6
- data/ext/gherkin_lexer_tt/gherkin_lexer_tt.c +0 -1936
- data/ext/gherkin_lexer_uk/extconf.rb +0 -6
- data/ext/gherkin_lexer_uk/gherkin_lexer_uk.c +0 -1941
- data/ext/gherkin_lexer_uz/extconf.rb +0 -6
- data/ext/gherkin_lexer_uz/gherkin_lexer_uz.c +0 -1651
- data/ext/gherkin_lexer_vi/extconf.rb +0 -6
- data/ext/gherkin_lexer_vi/gherkin_lexer_vi.c +0 -1458
- data/ext/gherkin_lexer_zh_cn/extconf.rb +0 -6
- data/ext/gherkin_lexer_zh_cn/gherkin_lexer_zh_cn.c +0 -1314
- data/ext/gherkin_lexer_zh_tw/extconf.rb +0 -6
- data/ext/gherkin_lexer_zh_tw/gherkin_lexer_zh_tw.c +0 -1307
- data/features/.cucumber/stepdefs.json +0 -244
- data/features/escaped_pipes.feature +0 -8
- data/features/feature_parser.feature +0 -237
- data/features/json_formatter.feature +0 -498
- data/features/json_parser.feature +0 -331
- data/features/native_lexer.feature +0 -19
- data/features/parser_with_native_lexer.feature +0 -205
- data/features/pretty_formatter.feature +0 -17
- data/features/step_definitions/eyeball_steps.rb +0 -3
- data/features/step_definitions/gherkin_steps.rb +0 -29
- data/features/step_definitions/json_formatter_steps.rb +0 -30
- data/features/step_definitions/json_parser_steps.rb +0 -21
- data/features/step_definitions/pretty_formatter_steps.rb +0 -85
- data/features/steps_parser.feature +0 -46
- data/features/support/env.rb +0 -41
- data/install_mingw_os_x.sh +0 -5
- data/js/.npmignore +0 -1
- data/js/lib/gherkin/lexer/.npmignore +0 -0
- data/lib/gherkin.rb +0 -2
- data/lib/gherkin/README.md +0 -7
- data/lib/gherkin/c_lexer.rb +0 -17
- data/lib/gherkin/formatter/ansi_escapes.rb +0 -97
- data/lib/gherkin/formatter/argument.rb +0 -16
- data/lib/gherkin/formatter/escaping.rb +0 -15
- data/lib/gherkin/formatter/filter_formatter.rb +0 -150
- data/lib/gherkin/formatter/hashable.rb +0 -25
- data/lib/gherkin/formatter/json_formatter.rb +0 -133
- data/lib/gherkin/formatter/line_filter.rb +0 -26
- data/lib/gherkin/formatter/model.rb +0 -281
- data/lib/gherkin/formatter/pretty_formatter.rb +0 -245
- data/lib/gherkin/formatter/regexp_filter.rb +0 -21
- data/lib/gherkin/formatter/step_printer.rb +0 -21
- data/lib/gherkin/formatter/tag_count_formatter.rb +0 -47
- data/lib/gherkin/formatter/tag_filter.rb +0 -19
- data/lib/gherkin/i18n.json +0 -786
- data/lib/gherkin/i18n.rb +0 -176
- data/lib/gherkin/json_parser.rb +0 -177
- data/lib/gherkin/lexer/ar.rb +0 -1170
- data/lib/gherkin/lexer/bg.rb +0 -1382
- data/lib/gherkin/lexer/bm.rb +0 -1250
- data/lib/gherkin/lexer/ca.rb +0 -1310
- data/lib/gherkin/lexer/cs.rb +0 -1246
- data/lib/gherkin/lexer/cy_gb.rb +0 -1032
- data/lib/gherkin/lexer/da.rb +0 -1048
- data/lib/gherkin/lexer/de.rb +0 -1166
- data/lib/gherkin/lexer/el.rb +0 -1628
- data/lib/gherkin/lexer/en.rb +0 -1156
- data/lib/gherkin/lexer/en_au.rb +0 -1486
- data/lib/gherkin/lexer/en_lol.rb +0 -934
- data/lib/gherkin/lexer/en_old.rb +0 -1037
- data/lib/gherkin/lexer/en_pirate.rb +0 -1210
- data/lib/gherkin/lexer/en_scouse.rb +0 -1362
- data/lib/gherkin/lexer/en_tx.rb +0 -1016
- data/lib/gherkin/lexer/encoding.rb +0 -41
- data/lib/gherkin/lexer/eo.rb +0 -995
- data/lib/gherkin/lexer/es.rb +0 -1140
- data/lib/gherkin/lexer/et.rb +0 -990
- data/lib/gherkin/lexer/fa.rb +0 -1214
- data/lib/gherkin/lexer/fi.rb +0 -969
- data/lib/gherkin/lexer/fr.rb +0 -1228
- data/lib/gherkin/lexer/gl.rb +0 -1117
- data/lib/gherkin/lexer/he.rb +0 -1118
- data/lib/gherkin/lexer/hi.rb +0 -1559
- data/lib/gherkin/lexer/hr.rb +0 -1066
- data/lib/gherkin/lexer/hu.rb +0 -1118
- data/lib/gherkin/lexer/i18n_lexer.rb +0 -48
- data/lib/gherkin/lexer/id.rb +0 -963
- data/lib/gherkin/lexer/is.rb +0 -1120
- data/lib/gherkin/lexer/it.rb +0 -1086
- data/lib/gherkin/lexer/ja.rb +0 -1418
- data/lib/gherkin/lexer/kn.rb +0 -1672
- data/lib/gherkin/lexer/ko.rb +0 -1102
- data/lib/gherkin/lexer/lt.rb +0 -1045
- data/lib/gherkin/lexer/lu.rb +0 -1132
- data/lib/gherkin/lexer/lv.rb +0 -1166
- data/lib/gherkin/lexer/nl.rb +0 -1115
- data/lib/gherkin/lexer/no.rb +0 -1060
- data/lib/gherkin/lexer/pa.rb +0 -1852
- data/lib/gherkin/lexer/pl.rb +0 -1457
- data/lib/gherkin/lexer/pt.rb +0 -1430
- data/lib/gherkin/lexer/ro.rb +0 -1164
- data/lib/gherkin/lexer/ru.rb +0 -1766
- data/lib/gherkin/lexer/sk.rb +0 -1452
- data/lib/gherkin/lexer/sr_cyrl.rb +0 -1803
- data/lib/gherkin/lexer/sr_latn.rb +0 -1294
- data/lib/gherkin/lexer/sv.rb +0 -1070
- data/lib/gherkin/lexer/th.rb +0 -2492
- data/lib/gherkin/lexer/tl.rb +0 -1726
- data/lib/gherkin/lexer/tr.rb +0 -1092
- data/lib/gherkin/lexer/tt.rb +0 -1643
- data/lib/gherkin/lexer/uk.rb +0 -1646
- data/lib/gherkin/lexer/uz.rb +0 -1376
- data/lib/gherkin/lexer/vi.rb +0 -1198
- data/lib/gherkin/lexer/zh_cn.rb +0 -1058
- data/lib/gherkin/lexer/zh_tw.rb +0 -1052
- data/lib/gherkin/listener/event.rb +0 -45
- data/lib/gherkin/listener/formatter_listener.rb +0 -150
- data/lib/gherkin/native.rb +0 -7
- data/lib/gherkin/native/java.rb +0 -72
- data/lib/gherkin/native/null.rb +0 -5
- data/lib/gherkin/native/therubyracer.rb +0 -41
- data/lib/gherkin/parser/meta.txt +0 -5
- data/lib/gherkin/parser/parser.rb +0 -166
- data/lib/gherkin/parser/root.txt +0 -11
- data/lib/gherkin/parser/steps.txt +0 -4
- data/lib/gherkin/platform.rb +0 -13
- data/lib/gherkin/rubify.rb +0 -31
- data/lib/gherkin/tag_expression.rb +0 -63
- data/ragel/lexer.c.rl.erb +0 -454
- data/ragel/lexer.java.rl.erb +0 -219
- data/ragel/lexer.js.rl.erb +0 -322
- data/ragel/lexer.rb.rl.erb +0 -179
- data/ragel/lexer_common.rl.erb +0 -50
- data/spec/gherkin/c_lexer_spec.rb +0 -22
- data/spec/gherkin/fixtures/1.feature +0 -8
- data/spec/gherkin/fixtures/comments_in_table.feature +0 -9
- data/spec/gherkin/fixtures/complex.feature +0 -45
- data/spec/gherkin/fixtures/complex.json +0 -139
- data/spec/gherkin/fixtures/complex_for_filtering.feature +0 -60
- data/spec/gherkin/fixtures/complex_with_tags.feature +0 -61
- data/spec/gherkin/fixtures/dos_line_endings.feature +0 -45
- data/spec/gherkin/fixtures/examples_with_only_header.feature +0 -14
- data/spec/gherkin/fixtures/hantu_pisang.feature +0 -35
- data/spec/gherkin/fixtures/i18n_fr.feature +0 -14
- data/spec/gherkin/fixtures/i18n_fr2.feature +0 -8
- data/spec/gherkin/fixtures/i18n_no.feature +0 -7
- data/spec/gherkin/fixtures/i18n_pt1.feature +0 -44
- data/spec/gherkin/fixtures/i18n_pt2.feature +0 -4
- data/spec/gherkin/fixtures/i18n_pt3.feature +0 -4
- data/spec/gherkin/fixtures/i18n_pt4.feature +0 -4
- data/spec/gherkin/fixtures/i18n_zh-CN.feature +0 -9
- data/spec/gherkin/fixtures/iso-8859-1.feature +0 -6
- data/spec/gherkin/fixtures/issue_145.feature +0 -22
- data/spec/gherkin/fixtures/scenario_outline_with_tags.feature +0 -13
- data/spec/gherkin/fixtures/scenario_without_steps.feature +0 -5
- data/spec/gherkin/fixtures/simple_with_comments.feature +0 -7
- data/spec/gherkin/fixtures/simple_with_tags.feature +0 -11
- data/spec/gherkin/fixtures/with_bom.feature +0 -3
- data/spec/gherkin/fixtures/with_bom_and_language_spec.feature +0 -4
- data/spec/gherkin/formatter/ansi_escapes_spec.rb +0 -32
- data/spec/gherkin/formatter/filter_formatter_spec.rb +0 -204
- data/spec/gherkin/formatter/json_formatter_spec.rb +0 -179
- data/spec/gherkin/formatter/model_spec.rb +0 -28
- data/spec/gherkin/formatter/pretty_formatter_spec.rb +0 -184
- data/spec/gherkin/formatter/spaces.feature +0 -9
- data/spec/gherkin/formatter/step_printer_spec.rb +0 -55
- data/spec/gherkin/formatter/tabs.feature +0 -9
- data/spec/gherkin/formatter/tag_count_formatter_spec.rb +0 -30
- data/spec/gherkin/i18n_spec.rb +0 -256
- data/spec/gherkin/java_lexer_spec.rb +0 -20
- data/spec/gherkin/json_parser_spec.rb +0 -165
- data/spec/gherkin/lexer/i18n_lexer_spec.rb +0 -65
- data/spec/gherkin/native_lexer_spec.rb +0 -29
- data/spec/gherkin/parser/parser_spec.rb +0 -16
- data/spec/gherkin/rubify_spec.rb +0 -23
- data/spec/gherkin/sexp_recorder.rb +0 -59
- data/spec/gherkin/shared/doc_string_group.rb +0 -161
- data/spec/gherkin/shared/encoding_group.rb +0 -48
- data/spec/gherkin/shared/lexer_group.rb +0 -589
- data/spec/gherkin/shared/row_group.rb +0 -123
- data/spec/gherkin/shared/tags_group.rb +0 -52
- data/spec/gherkin/tag_expression_spec.rb +0 -146
- data/spec/spec_helper.rb +0 -94
- data/tasks/apidoc.rake +0 -32
- data/tasks/bench.rake +0 -184
- data/tasks/bench/feature_builder.rb +0 -49
- data/tasks/bench/null_listener.rb +0 -4
- data/tasks/compile.rake +0 -83
- data/tasks/cucumber.rake +0 -23
- data/tasks/gems.rake +0 -46
- data/tasks/ikvm.rake +0 -126
- data/tasks/ragel_task.rb +0 -124
- data/tasks/release.rake +0 -34
- data/tasks/rspec.rake +0 -6
- data/tasks/yard/default/layout/html/bubble_32x32.png +0 -0
- data/tasks/yard/default/layout/html/bubble_48x48.png +0 -0
- data/tasks/yard/default/layout/html/footer.erb +0 -5
- data/tasks/yard/default/layout/html/index.erb +0 -1
- data/tasks/yard/default/layout/html/layout.erb +0 -25
- data/tasks/yard/default/layout/html/logo.erb +0 -1
- data/tasks/yard/default/layout/html/setup.rb +0 -4
@@ -1,45 +0,0 @@
|
|
1
|
-
module Gherkin
|
2
|
-
module Listener
|
3
|
-
class Event < Array
|
4
|
-
def event
|
5
|
-
self[0]
|
6
|
-
end
|
7
|
-
|
8
|
-
def keyword
|
9
|
-
self[1]
|
10
|
-
end
|
11
|
-
|
12
|
-
def line_match?(lines)
|
13
|
-
lines.include?(line)
|
14
|
-
end
|
15
|
-
|
16
|
-
def name_match?(name_regexen)
|
17
|
-
return false unless [:feature, :background, :scenario, :scenario_outline, :examples].include?(event)
|
18
|
-
name_regexen.detect{|name_regex| name =~ name_regex}
|
19
|
-
end
|
20
|
-
|
21
|
-
def replay(listener)
|
22
|
-
begin
|
23
|
-
listener.__send__(event, *args)
|
24
|
-
rescue ArgumentError => e
|
25
|
-
e.message << "\nListener: #{listener.class}, args: #{args.inspect}"
|
26
|
-
raise e
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
30
|
-
private
|
31
|
-
|
32
|
-
def name
|
33
|
-
self[2]
|
34
|
-
end
|
35
|
-
|
36
|
-
def line
|
37
|
-
self[-1]
|
38
|
-
end
|
39
|
-
|
40
|
-
def args
|
41
|
-
self[1..-1]
|
42
|
-
end
|
43
|
-
end
|
44
|
-
end
|
45
|
-
end
|
@@ -1,150 +0,0 @@
|
|
1
|
-
require 'gherkin/native'
|
2
|
-
require 'gherkin/formatter/model'
|
3
|
-
|
4
|
-
module Gherkin
|
5
|
-
module Listener
|
6
|
-
# Adapter from the "raw" Gherkin <tt>Listener</tt> API
|
7
|
-
# to the slightly more high-level <tt>Formatter</tt> API,
|
8
|
-
# which is easier to implement (less state to keep track of).
|
9
|
-
class FormatterListener
|
10
|
-
native_impl('gherkin')
|
11
|
-
|
12
|
-
def initialize(formatter)
|
13
|
-
@formatter = formatter
|
14
|
-
@stash = Stash.new
|
15
|
-
@current_builder = nil
|
16
|
-
end
|
17
|
-
|
18
|
-
def comment(value, line)
|
19
|
-
@stash.comment Formatter::Model::Comment.new(value, line)
|
20
|
-
end
|
21
|
-
|
22
|
-
def tag(name, line)
|
23
|
-
@stash.tag Formatter::Model::Tag.new(name, line)
|
24
|
-
end
|
25
|
-
|
26
|
-
def feature(keyword, name, description, line)
|
27
|
-
@stash.feature(name) do |comments, tags, id|
|
28
|
-
replay Formatter::Model::Feature.new(comments, tags, keyword, name, description, line, id)
|
29
|
-
end
|
30
|
-
end
|
31
|
-
|
32
|
-
def background(keyword, name, description, line)
|
33
|
-
@stash.feature_element(name) do |comments, tags, id|
|
34
|
-
replay Formatter::Model::Background.new(comments, keyword, name, description, line)
|
35
|
-
end
|
36
|
-
end
|
37
|
-
|
38
|
-
def scenario(keyword, name, description, line)
|
39
|
-
replay_step_or_examples
|
40
|
-
@stash.feature_element(name) do |comments, tags, id|
|
41
|
-
replay Formatter::Model::Scenario.new(comments, tags, keyword, name, description, line, id)
|
42
|
-
end
|
43
|
-
end
|
44
|
-
|
45
|
-
def scenario_outline(keyword, name, description, line)
|
46
|
-
replay_step_or_examples
|
47
|
-
@stash.feature_element(name) do |comments, tags, id|
|
48
|
-
replay Formatter::Model::ScenarioOutline.new(comments, tags, keyword, name, description, line, id)
|
49
|
-
end
|
50
|
-
end
|
51
|
-
|
52
|
-
def examples(keyword, name, description, line)
|
53
|
-
replay_step_or_examples
|
54
|
-
@stash.examples(name) do |comments, tags, id|
|
55
|
-
@current_builder = Formatter::Model::Examples::Builder.new(comments, tags, keyword, name, description, line, id)
|
56
|
-
end
|
57
|
-
end
|
58
|
-
|
59
|
-
def step(keyword, name, line)
|
60
|
-
replay_step_or_examples
|
61
|
-
@stash.step do |comments|
|
62
|
-
@current_builder = Formatter::Model::Step::Builder.new(comments, keyword, name, line)
|
63
|
-
end
|
64
|
-
end
|
65
|
-
|
66
|
-
def row(cells, line)
|
67
|
-
@stash.row do |comments, id|
|
68
|
-
@current_builder.row(comments, cells, line, id)
|
69
|
-
end
|
70
|
-
end
|
71
|
-
|
72
|
-
def doc_string(content_type, value, line)
|
73
|
-
@current_builder.doc_string(value, content_type, line)
|
74
|
-
end
|
75
|
-
|
76
|
-
def eof
|
77
|
-
replay_step_or_examples
|
78
|
-
@formatter.eof
|
79
|
-
end
|
80
|
-
|
81
|
-
def syntax_error(state, ev, legal_events, uri, line)
|
82
|
-
@formatter.syntax_error(state, ev, legal_events, uri, line)
|
83
|
-
end
|
84
|
-
|
85
|
-
private
|
86
|
-
|
87
|
-
def replay(element)
|
88
|
-
element.replay(@formatter)
|
89
|
-
end
|
90
|
-
|
91
|
-
class Stash
|
92
|
-
attr_reader :comments, :tags, :ids
|
93
|
-
|
94
|
-
def initialize
|
95
|
-
@comments, @tags, @ids = [], [], []
|
96
|
-
@row_index = 0
|
97
|
-
end
|
98
|
-
|
99
|
-
def comment(comment)
|
100
|
-
@comments << comment
|
101
|
-
end
|
102
|
-
|
103
|
-
def feature(name)
|
104
|
-
@feature_id = id(name)
|
105
|
-
yield @comments, @tags, @feature_id
|
106
|
-
@comments, @tags = [], []
|
107
|
-
end
|
108
|
-
|
109
|
-
def feature_element(name)
|
110
|
-
@feature_element_id = "#{@feature_id};#{id(name)}"
|
111
|
-
yield @comments, @tags, @feature_element_id
|
112
|
-
@comments, @tags = [], []
|
113
|
-
end
|
114
|
-
|
115
|
-
def examples(name)
|
116
|
-
@examples_id = "#{@feature_element_id};#{id(name)}"
|
117
|
-
@row_index = 0
|
118
|
-
yield @comments, @tags, @examples_id
|
119
|
-
@comments, @tags = [], []
|
120
|
-
end
|
121
|
-
|
122
|
-
def step
|
123
|
-
@row_index += 1
|
124
|
-
yield @comments
|
125
|
-
@comments = []
|
126
|
-
end
|
127
|
-
|
128
|
-
def row
|
129
|
-
@row_index += 1
|
130
|
-
yield @comments, defined?(@examples_id) ? "#{@examples_id};#{@row_index}" : :undefined_examples_id
|
131
|
-
@comments = []
|
132
|
-
end
|
133
|
-
|
134
|
-
def tag(tag)
|
135
|
-
@tags << tag
|
136
|
-
end
|
137
|
-
|
138
|
-
def id(name)
|
139
|
-
(name || '').gsub(/[\s_]/, '-').downcase
|
140
|
-
end
|
141
|
-
end
|
142
|
-
|
143
|
-
def replay_step_or_examples
|
144
|
-
return unless @current_builder
|
145
|
-
replay(@current_builder)
|
146
|
-
@current_builder = nil
|
147
|
-
end
|
148
|
-
end
|
149
|
-
end
|
150
|
-
end
|
data/lib/gherkin/native.rb
DELETED
data/lib/gherkin/native/java.rb
DELETED
@@ -1,72 +0,0 @@
|
|
1
|
-
class Class
|
2
|
-
class IOWriter < Java.java.io.Writer
|
3
|
-
def initialize(io)
|
4
|
-
@io = io
|
5
|
-
end
|
6
|
-
|
7
|
-
def write(cbuf, off, len)
|
8
|
-
@io.write(cbuf.unpack("U*")[off..len].pack("U*"))
|
9
|
-
end
|
10
|
-
|
11
|
-
def flush
|
12
|
-
@io.flush
|
13
|
-
end
|
14
|
-
|
15
|
-
def close
|
16
|
-
@io.close
|
17
|
-
end
|
18
|
-
end
|
19
|
-
|
20
|
-
# Causes a Java class to be instantiated instead of the Ruby class when
|
21
|
-
# running on JRuby. This is used to test both pure Java and pure Ruby classes
|
22
|
-
# from the same Ruby based test suite. The Java Class must have a package name
|
23
|
-
# that corresponds with the Ruby class.
|
24
|
-
def native_impl(lib)
|
25
|
-
require "#{lib}.jar"
|
26
|
-
|
27
|
-
class << self
|
28
|
-
def new(*args)
|
29
|
-
begin
|
30
|
-
java_class.new(*javaify(args))
|
31
|
-
rescue ArgumentError => e
|
32
|
-
e.message << "\n#{java_class.name}"
|
33
|
-
raise e
|
34
|
-
rescue NameError => e
|
35
|
-
e.message << "\n args: #{args.inspect}"
|
36
|
-
raise e
|
37
|
-
end
|
38
|
-
end
|
39
|
-
|
40
|
-
def javaify(arg)
|
41
|
-
if Array === arg
|
42
|
-
arg.map{|a| javaify(a)}
|
43
|
-
else
|
44
|
-
case(arg)
|
45
|
-
when Regexp
|
46
|
-
java.util.regex.Pattern.compile(arg.source)
|
47
|
-
when Symbol
|
48
|
-
arg.to_s
|
49
|
-
when IO, StringIO
|
50
|
-
IOWriter.new(arg)
|
51
|
-
else
|
52
|
-
arg
|
53
|
-
end
|
54
|
-
end
|
55
|
-
end
|
56
|
-
|
57
|
-
def ===(object)
|
58
|
-
super || object.java_kind_of?(java_class)
|
59
|
-
end
|
60
|
-
|
61
|
-
def java_class
|
62
|
-
names = self.name.split('::')
|
63
|
-
package = Java
|
64
|
-
names[0..-2].each do |module_name|
|
65
|
-
package = package.__send__(module_name.downcase)
|
66
|
-
end
|
67
|
-
|
68
|
-
package.__send__(names[-1])
|
69
|
-
end
|
70
|
-
end
|
71
|
-
end
|
72
|
-
end
|
data/lib/gherkin/native/null.rb
DELETED
@@ -1,41 +0,0 @@
|
|
1
|
-
require 'v8'
|
2
|
-
|
3
|
-
class Class
|
4
|
-
def native_impl(lib)
|
5
|
-
class << self
|
6
|
-
def new(*args)
|
7
|
-
js = {
|
8
|
-
# Add more mappings here if needed. The mappings are only used by test code.
|
9
|
-
'Gherkin::Formatter::JSONFormatter' => 'js/lib/gherkin/formatter/json_formatter.js',
|
10
|
-
'Gherkin::Lexer::En' => 'js/lib/gherkin/lexer/en.js'
|
11
|
-
}[self.name]
|
12
|
-
if(js)
|
13
|
-
Proxy.new(js, *args)
|
14
|
-
else
|
15
|
-
super(*args)
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
|
-
class Proxy
|
22
|
-
def initialize(js, *args)
|
23
|
-
cxt = V8::Context.new
|
24
|
-
cxt['module'] = {}
|
25
|
-
|
26
|
-
# Mimic Node.js / Firebug console.log
|
27
|
-
cxt['console'] = STDOUT
|
28
|
-
def STDOUT.log(*a)
|
29
|
-
puts sprintf(*a.map(&:to_s))
|
30
|
-
end
|
31
|
-
|
32
|
-
cxt.load(js)
|
33
|
-
@js_obj = cxt['module']['exports'].new(*args)
|
34
|
-
end
|
35
|
-
|
36
|
-
def method_missing(name, *args)
|
37
|
-
a = args.map{|a| a.respond_to?(:to_hash) ? a.to_hash : a}
|
38
|
-
@js_obj.__send__(name, *a)
|
39
|
-
end
|
40
|
-
end
|
41
|
-
end
|
data/lib/gherkin/parser/meta.txt
DELETED
@@ -1,5 +0,0 @@
|
|
1
|
-
| | feature | background | scenario | scenario_outline | examples | step | row | doc_string | eof | comment | tag |
|
2
|
-
| meta | E | E | E | E | E | E | E | E | eof | comment | tag |
|
3
|
-
| comment | pop() | pop() | pop() | pop() | pop() | pop() | pop() | pop() | eof | pop() | tag |
|
4
|
-
| tag | pop() | E | pop() | pop() | pop() | E | E | E | E | E | tag |
|
5
|
-
| eof | E | E | E | E | E | E | E | E | E | E | E |
|
@@ -1,166 +0,0 @@
|
|
1
|
-
require 'gherkin/i18n'
|
2
|
-
require 'gherkin/lexer/i18n_lexer'
|
3
|
-
require 'gherkin/native'
|
4
|
-
require 'gherkin/listener/formatter_listener'
|
5
|
-
|
6
|
-
module Gherkin
|
7
|
-
module Parser
|
8
|
-
class ParseError < StandardError
|
9
|
-
def initialize(state, new_state, expected_states, uri, line)
|
10
|
-
super("Parse error at #{uri}:#{line}. Found #{new_state} when expecting one of: #{expected_states.join(', ')}. (Current state: #{state}).")
|
11
|
-
end
|
12
|
-
end
|
13
|
-
|
14
|
-
class Parser
|
15
|
-
native_impl('gherkin')
|
16
|
-
|
17
|
-
# Initialize the parser. +machine_name+ refers to a state machine table.
|
18
|
-
def initialize(formatter, raise_on_error=true, machine_name='root', force_ruby=false, iso_code = 'en')
|
19
|
-
@formatter = formatter
|
20
|
-
@listener = Listener::FormatterListener.new(@formatter)
|
21
|
-
@raise_on_error = raise_on_error
|
22
|
-
@machine_name = machine_name
|
23
|
-
@machines = []
|
24
|
-
@lexer = Gherkin::Lexer::I18nLexer.new(self, force_ruby, iso_code)
|
25
|
-
end
|
26
|
-
|
27
|
-
def parse(gherkin, feature_uri, line_offset)
|
28
|
-
@formatter.uri(feature_uri)
|
29
|
-
@line_offset = line_offset
|
30
|
-
@feature_uri = feature_uri
|
31
|
-
push_machine(@machine_name)
|
32
|
-
begin
|
33
|
-
@lexer.scan(gherkin)
|
34
|
-
ensure
|
35
|
-
pop_machine
|
36
|
-
end
|
37
|
-
end
|
38
|
-
|
39
|
-
def i18n_language
|
40
|
-
@lexer.i18n_language
|
41
|
-
end
|
42
|
-
|
43
|
-
def errors
|
44
|
-
@lexer.errors
|
45
|
-
end
|
46
|
-
|
47
|
-
[:comment, :tag, :feature, :background, :scenario, :scenario_outline, :examples, :step, :doc_string, :row, :eof].each do |m|
|
48
|
-
define_method(m) do |*args|
|
49
|
-
if(event(m.to_s, args[-1]))
|
50
|
-
@listener.__send__(m, *args)
|
51
|
-
end
|
52
|
-
end
|
53
|
-
end
|
54
|
-
|
55
|
-
def event(ev, line)
|
56
|
-
l = line ? @line_offset+line : nil
|
57
|
-
machine.event(ev, l) do |state, legal_events|
|
58
|
-
if @raise_on_error
|
59
|
-
raise ParseError.new(state, ev, legal_events, @feature_uri, l)
|
60
|
-
else
|
61
|
-
# Only used for testing
|
62
|
-
@listener.syntax_error(state, ev, legal_events, @feature_uri, l)
|
63
|
-
end
|
64
|
-
end
|
65
|
-
end
|
66
|
-
|
67
|
-
def push_machine(name)
|
68
|
-
@machines.push(Machine.new(self, name))
|
69
|
-
end
|
70
|
-
|
71
|
-
def pop_machine
|
72
|
-
@machines.pop
|
73
|
-
end
|
74
|
-
|
75
|
-
def machine
|
76
|
-
@machines[-1]
|
77
|
-
end
|
78
|
-
|
79
|
-
def expected
|
80
|
-
machine.expected
|
81
|
-
end
|
82
|
-
|
83
|
-
def force_state(state)
|
84
|
-
machine.instance_variable_set('@state', state)
|
85
|
-
end
|
86
|
-
|
87
|
-
class Machine
|
88
|
-
def initialize(parser, name)
|
89
|
-
@parser = parser
|
90
|
-
@name = name
|
91
|
-
@transition_map = transition_map(name)
|
92
|
-
@state = name
|
93
|
-
end
|
94
|
-
|
95
|
-
def event(ev, line)
|
96
|
-
states = @transition_map[@state]
|
97
|
-
raise "Unknown state: #{@state.inspect} for machine #{@name}" if states.nil?
|
98
|
-
new_state = states[ev]
|
99
|
-
case new_state
|
100
|
-
when "E"
|
101
|
-
yield @state, expected
|
102
|
-
when /push\((.+)\)/
|
103
|
-
@parser.push_machine($1)
|
104
|
-
@parser.event(ev, line)
|
105
|
-
when "pop()"
|
106
|
-
@parser.pop_machine()
|
107
|
-
@parser.event(ev, line)
|
108
|
-
else
|
109
|
-
raise "Unknown transition: #{ev.inspect} among #{states.inspect} for machine #{@name}" if new_state.nil?
|
110
|
-
@state = new_state
|
111
|
-
end
|
112
|
-
end
|
113
|
-
|
114
|
-
def expected
|
115
|
-
allowed = @transition_map[@state].find_all { |_, action| action != "E" }
|
116
|
-
allowed.collect { |state| state[0] }.sort - ['eof']
|
117
|
-
end
|
118
|
-
|
119
|
-
private
|
120
|
-
|
121
|
-
@@transition_maps = {}
|
122
|
-
|
123
|
-
def transition_map(name)
|
124
|
-
@@transition_maps[name] ||= build_transition_map(name)
|
125
|
-
end
|
126
|
-
|
127
|
-
def build_transition_map(name)
|
128
|
-
table = transition_table(name)
|
129
|
-
events = table.shift[1..-1]
|
130
|
-
table.inject({}) do |machine, actions|
|
131
|
-
state = actions.shift
|
132
|
-
machine[state] = Hash[*events.zip(actions).flatten]
|
133
|
-
machine
|
134
|
-
end
|
135
|
-
end
|
136
|
-
|
137
|
-
def transition_table(name)
|
138
|
-
state_machine_reader = StateMachineReader.new
|
139
|
-
lexer = Gherkin::I18n.new('en').lexer(state_machine_reader)
|
140
|
-
machine = File.dirname(__FILE__) + "/#{name}.txt"
|
141
|
-
lexer.scan(File.read(machine))
|
142
|
-
state_machine_reader.rows
|
143
|
-
end
|
144
|
-
|
145
|
-
class StateMachineReader
|
146
|
-
attr_reader :rows
|
147
|
-
|
148
|
-
def initialize
|
149
|
-
@rows = []
|
150
|
-
end
|
151
|
-
|
152
|
-
def uri(uri)
|
153
|
-
end
|
154
|
-
|
155
|
-
def row(row, line_number)
|
156
|
-
@rows << row
|
157
|
-
end
|
158
|
-
|
159
|
-
def eof
|
160
|
-
end
|
161
|
-
end
|
162
|
-
|
163
|
-
end
|
164
|
-
end
|
165
|
-
end
|
166
|
-
end
|