gherkin 1.0.9-i386-mswin32 → 1.0.10-i386-mswin32

Sign up to get free protection for your applications and to get access to all the features.
data/History.txt CHANGED
@@ -1,3 +1,12 @@
1
+ == 1.0.10 (2010-04-16)
2
+
3
+ === New Features
4
+ * Added Esperanto and added a Russian synonym for Feature. (Antono Vasiljev)
5
+ * Pure Java implementation of FilterListener and TagExpression (Mike Gaffney, Aslak Hellesøy)
6
+
7
+ === Changed Features
8
+ * TagExpression takes array args instead of varargs. (Aslak Hellesøy)
9
+
1
10
  == 1.0.9 (2010-04-12)
2
11
 
3
12
  === Bugfixes
data/README.rdoc CHANGED
@@ -30,7 +30,7 @@ E.g. in Bash, export RL_LANG="en,fr,no". This can be quite helpful when modifyin
30
30
 
31
31
  * Bump version in the VERSION.yml file and:
32
32
  ** java/pom.xml
33
- ** ikvm/Gherkin/Gherkin,csproj
33
+ ** ikvm/Gherkin/Gherkin.csproj
34
34
  * rake release:ALL
35
35
  * Announce on Cucumber list, IRC and Twitter.
36
36
 
data/VERSION.yml CHANGED
@@ -1,4 +1,4 @@
1
1
  ---
2
2
  :minor: 0
3
- :patch: 9
3
+ :patch: 10
4
4
  :major: 1
data/lib/gherkin/i18n.rb CHANGED
@@ -35,6 +35,14 @@ module Gherkin
35
35
 
36
36
  unique_keywords.flatten.compact.sort.reverse.uniq.join('|').gsub(/\*/, '\*')
37
37
  end
38
+
39
+ def code_keywords
40
+ all.map{|i18n| i18n.code_keywords}.flatten.uniq.sort
41
+ end
42
+
43
+ def code_keyword_for(gherkin_keyword)
44
+ gherkin_keyword.gsub(/[\s',]/, '').strip
45
+ end
38
46
  end
39
47
 
40
48
  attr_reader :key
@@ -120,7 +128,7 @@ module Gherkin
120
128
 
121
129
  # Keywords that can be used in code
122
130
  def code_keywords
123
- result = gwt_keywords.map{|keyword| keyword.gsub(/[\s',]/, '').strip}
131
+ result = gwt_keywords.map{|keyword| self.class.code_keyword_for(keyword)}
124
132
  result.delete('*')
125
133
  result
126
134
  end
data/lib/gherkin/i18n.yml CHANGED
@@ -74,7 +74,7 @@
74
74
  scenario: Scenario
75
75
  scenario_outline: Scenario Amlinellol
76
76
  examples: Enghreifftiau
77
- given: "*|anrhegedig a"
77
+ given: "*|Anrhegedig a"
78
78
  when: "*|Pryd"
79
79
  then: "*|Yna"
80
80
  and: "*|A"
@@ -170,6 +170,19 @@
170
170
  then: "*|Then y'all"
171
171
  and: "*|And y'all"
172
172
  but: "*|But y'all"
173
+ "eo":
174
+ name: Esperanto
175
+ native: Esperanto
176
+ feature: Trajto
177
+ background: Fono
178
+ scenario: Scenaro
179
+ scenario_outline: Konturo de la scenaro
180
+ examples: Ekzemploj
181
+ given: "*|Donitaĵo"
182
+ when: "*|Se"
183
+ then: "*|Do"
184
+ and: "*|Kaj"
185
+ but: "*|Sed"
173
186
  "es":
174
187
  name: Spanish
175
188
  native: español
@@ -420,7 +433,7 @@
420
433
  "ru":
421
434
  name: Russian
422
435
  native: русский
423
- feature: Функционал
436
+ feature: Функционал|Фича
424
437
  background: Предыстория
425
438
  scenario: Сценарий
426
439
  scenario_outline: Структура сценария
@@ -7,13 +7,35 @@ class Class
7
7
  if defined?(JRUBY_VERSION)
8
8
  require jar
9
9
  class << self
10
- define_method(:new) do |*args|
10
+ def javaify(arg)
11
+ if Array === arg
12
+ arg.map{|a| javaify(a)}
13
+ else
14
+ case(arg)
15
+ when Regexp
16
+ java.util.regex.Pattern.compile(arg.source)
17
+ else
18
+ arg
19
+ end
20
+ end
21
+ end
22
+
23
+ def new(*args)
24
+ java_class.new(*javaify(args))
25
+ end
26
+
27
+ def ===(object)
28
+ super || object.java_kind_of?(java_class)
29
+ end
30
+
31
+ def java_class
11
32
  names = self.name.split('::')
12
33
  package = Java
13
34
  names[0..-2].each do |module_name|
14
35
  package = package.__send__(module_name.downcase)
15
36
  end
16
- package.__send__(names[-1]).new(*args)
37
+
38
+ package.__send__(names[-1])
17
39
  end
18
40
  end
19
41
  end
@@ -5,6 +5,9 @@ module Gherkin
5
5
  module Parser
6
6
  # This class filters events based on filter criteria.
7
7
  class FilterListener
8
+ require 'gherkin/java_impl'
9
+ java_impl('gherkin.jar')
10
+
8
11
  # Creates a new instance that replays events to +listener+, filtered by +filters+,
9
12
  # a Hash that can contain:
10
13
  #
@@ -138,7 +141,7 @@ module Gherkin
138
141
  when Regexp
139
142
  :name_match?
140
143
  when String
141
- TagExpression.new(*filters)
144
+ TagExpression.new(filters)
142
145
  end
143
146
  end
144
147
 
@@ -147,8 +150,7 @@ module Gherkin
147
150
  end
148
151
 
149
152
  def header_row_already_buffered?
150
- return false unless @examples_buffer.any?
151
- @examples_buffer[-1].event == :row
153
+ return @examples_buffer.any? && @examples_buffer[-1].event == :row
152
154
  end
153
155
 
154
156
  def filter_match?(*sexps)
@@ -157,8 +159,7 @@ module Gherkin
157
159
  end
158
160
 
159
161
  def tag_match?
160
- return false unless TagExpression === @filter_method
161
- @filter_method.eval(*current_tags)
162
+ return TagExpression === @filter_method && @filter_method.eval(current_tags)
162
163
  end
163
164
 
164
165
  def replay_buffers
@@ -1,9 +1,12 @@
1
1
  module Gherkin
2
2
  module Parser
3
3
  class TagExpression
4
+ require 'gherkin/java_impl'
5
+ java_impl('gherkin.jar')
6
+
4
7
  attr_reader :limits
5
8
 
6
- def initialize(*tag_expressions)
9
+ def initialize(tag_expressions)
7
10
  @ands = []
8
11
  @limits = {}
9
12
  tag_expressions.each do |expr|
@@ -15,7 +18,7 @@ module Gherkin
15
18
  @ands.empty?
16
19
  end
17
20
 
18
- def eval(*tags)
21
+ def eval(tags)
19
22
  return true if @ands.flatten.empty?
20
23
  vars = Hash[*tags.map{|tag| [tag, true]}.flatten]
21
24
  !!Kernel.eval(ruby_expression)
@@ -18,5 +18,9 @@ module Gherkin
18
18
  @lexer.scan("Feature: foo\n")
19
19
  @lexer.i18n_language.key.should == "en"
20
20
  end
21
+
22
+ it "should === its ruby class, even when the impl is Java" do
23
+ I18nLexer.should === I18nLexer.new(SexpRecorder.new, true)
24
+ end
21
25
  end
22
26
  end
@@ -3,7 +3,7 @@ require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
3
3
 
4
4
  module Gherkin
5
5
  module Lexer
6
- describe "i18n parsing" do
6
+ describe I18n do
7
7
  before do
8
8
  @listener = Gherkin::SexpRecorder.new
9
9
  end
@@ -60,6 +60,14 @@ module Gherkin
60
60
  [:eof]
61
61
  ]
62
62
  end
63
+
64
+ describe 'keywords' do
65
+ it "should have code keywords without space, comma or apostrophe" do
66
+ ['Akkor', 'Etantdonné', 'Lorsque', '假設'].each do |code_keyword|
67
+ I18n.code_keywords.should include(code_keyword)
68
+ end
69
+ end
70
+ end
63
71
  end
64
72
  end
65
73
  end
@@ -31,8 +31,6 @@ module Gherkin
31
31
  end
32
32
 
33
33
  def scan(listener, filters)
34
- tag_expressions = filters.delete(:tag_expressions)
35
- filters[:tag_expression] = TagExpression.new(*tag_expressions) if tag_expressions
36
34
  filter_listener = FilterListener.new(listener, filters)
37
35
  parser = Gherkin::Parser::Parser.new(filter_listener, true, "root")
38
36
  lexer = Gherkin::I18nLexer.new(parser, true)
@@ -35,7 +35,7 @@ module Gherkin
35
35
  it "should be reusable for several feature files (native lexer: #{native})" do
36
36
  listener = mock('listener', :null_object => true)
37
37
  parser = Parser.new(listener, true)
38
- lexer = I18nLexer.new(parser, native)
38
+ lexer = Gherkin::I18nLexer.new(parser, native)
39
39
  feature = <<-EOF
40
40
  Feature: foo
41
41
  Scenario: bar
@@ -6,113 +6,109 @@ module Gherkin
6
6
  describe TagExpression do
7
7
  context "no tags" do
8
8
  before(:each) do
9
- @e = TagExpression.new
9
+ @e = TagExpression.new([])
10
10
  end
11
11
 
12
12
  it "should match @foo" do
13
- @e.eval('@foo').should == true
13
+ @e.eval(['@foo']).should == true
14
14
  end
15
15
 
16
16
  it "should match empty tags" do
17
- @e.eval().should == true
17
+ @e.eval([]).should == true
18
18
  end
19
19
  end
20
20
 
21
21
  context "@foo" do
22
22
  before(:each) do
23
- @e = TagExpression.new('@foo')
23
+ @e = TagExpression.new(['@foo'])
24
24
  end
25
25
 
26
26
  it "should match @foo" do
27
- @e.eval('@foo').should == true
27
+ @e.eval(['@foo']).should == true
28
28
  end
29
29
 
30
30
  it "should not match @bar" do
31
- @e.eval('@bar').should == false
31
+ @e.eval(['@bar']).should == false
32
+ end
33
+
34
+ it "should not match no tags" do
35
+ @e.eval([]).should == false
32
36
  end
33
37
  end
34
38
 
35
39
  context "!@foo" do
36
40
  before(:each) do
37
- @e = TagExpression.new('~@foo')
41
+ @e = TagExpression.new(['~@foo'])
38
42
  end
39
43
 
40
44
  it "should match @bar" do
41
- @e.eval('@bar').should == true
45
+ @e.eval(['@bar']).should == true
42
46
  end
43
47
 
44
48
  it "should not match @foo" do
45
- @e.eval('@foo').should == false
49
+ @e.eval(['@foo']).should == false
46
50
  end
47
51
  end
48
52
 
49
53
  context "@foo || @bar" do
50
54
  before(:each) do
51
- @e = TagExpression.new('@foo,@bar')
55
+ @e = TagExpression.new(['@foo,@bar'])
52
56
  end
53
57
 
54
58
  it "should match @foo" do
55
- @e.eval('@foo').should == true
59
+ @e.eval(['@foo']).should == true
56
60
  end
57
61
 
58
62
  it "should match @bar" do
59
- @e.eval('@bar').should == true
63
+ @e.eval(['@bar']).should == true
60
64
  end
61
65
 
62
66
  it "should not match @zap" do
63
- @e.eval('@zap').should == false
67
+ @e.eval(['@zap']).should == false
64
68
  end
65
69
  end
66
70
 
67
71
  context "(@foo || @bar) && !@zap" do
68
72
  before(:each) do
69
- @e = TagExpression.new('@foo,@bar', '~@zap')
73
+ @e = TagExpression.new(['@foo,@bar', '~@zap'])
70
74
  end
71
75
 
72
76
  it "should match @foo" do
73
- @e.eval('@foo').should == true
77
+ @e.eval(['@foo']).should == true
74
78
  end
75
79
 
76
80
  it "should not match @foo @zap" do
77
- @e.eval('@foo', '@zap').should == false
81
+ @e.eval(['@foo', '@zap']).should == false
78
82
  end
79
83
  end
80
84
 
81
85
  context "(@foo:3 || !@bar:4) && @zap:5" do
82
86
  before(:each) do
83
- @e = TagExpression.new('@foo:3,~@bar','@zap:5')
87
+ @e = TagExpression.new(['@foo:3,~@bar','@zap:5'])
84
88
  end
85
89
 
86
90
  it "should count tags for positive tags" do
87
- @e.limits.should == {'@foo' => 3, '@zap' => 5}
91
+ rubify_hash(@e.limits).should == {'@foo' => 3, '@zap' => 5}
88
92
  end
89
93
 
90
94
  it "should match @foo @zap" do
91
- @e.eval('@foo', '@zap').should == true
95
+ @e.eval(['@foo', '@zap']).should == true
92
96
  end
93
97
  end
94
98
 
95
99
  context "Parsing '@foo:3,~@bar', '@zap:5'" do
96
100
  before(:each) do
97
- @e = TagExpression.new(' @foo:3 , ~@bar ', ' @zap:5 ')
101
+ @e = TagExpression.new([' @foo:3 , ~@bar ', ' @zap:5 '])
98
102
  end
99
103
 
100
- it "should split and trim" do
101
- @e.__send__(:ruby_expression).should == "(!vars['@bar']||vars['@foo'])&&(vars['@zap'])"
104
+ unless defined?(JRUBY_VERSION)
105
+ it "should split and trim (ruby implementation detail)" do
106
+ @e.__send__(:ruby_expression).should == "(!vars['@bar']||vars['@foo'])&&(vars['@zap'])"
107
+ end
102
108
  end
103
109
 
104
110
  it "should have limits" do
105
- @e.limits.should == {"@zap"=>5, "@foo"=>3}
106
- end
107
- end
108
-
109
- context "Parsing ''" do
110
- before(:each) do
111
- @e = TagExpression.new('')
112
- end
113
-
114
- it "should ignore empty tags" do
115
- @e.eval("@foo").should == true
111
+ rubify_hash(@e.limits).should == {"@zap"=>5, "@foo"=>3}
116
112
  end
117
113
  end
118
114
  end
data/spec/spec_helper.rb CHANGED
@@ -39,6 +39,16 @@ module GherkinSpecHelper
39
39
  def scan_file(file)
40
40
  @lexer.scan(File.new(File.dirname(__FILE__) + "/gherkin/fixtures/" + file).read)
41
41
  end
42
+
43
+ def rubify_hash(hash)
44
+ if defined?(JRUBY_VERSION)
45
+ h = {}
46
+ hash.keySet.each{|key| h[key] = hash[key]}
47
+ h
48
+ else
49
+ hash
50
+ end
51
+ end
42
52
  end
43
53
 
44
54
  Spec::Runner.configure do |c|
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 1
7
7
  - 0
8
- - 9
9
- version: 1.0.9
8
+ - 10
9
+ version: 1.0.10
10
10
  platform: i386-mswin32
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-04-12 00:00:00 +02:00
19
+ date: 2010-04-16 00:00:00 +02:00
20
20
  default_executable: gherkin
21
21
  dependencies:
22
22
  - !ruby/object:Gem::Dependency
@@ -146,6 +146,7 @@ files:
146
146
  - lib/gherkin_lexer_en_lol.so
147
147
  - lib/gherkin_lexer_en_scouse.so
148
148
  - lib/gherkin_lexer_en_tx.so
149
+ - lib/gherkin_lexer_eo.so
149
150
  - lib/gherkin_lexer_es.so
150
151
  - lib/gherkin_lexer_et.so
151
152
  - lib/gherkin_lexer_fi.so