gherkin 1.0.23-java → 1.0.24-java

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.
data/History.txt CHANGED
@@ -1,3 +1,8 @@
1
+ == 1.0.24 (2010-05-02)
2
+
3
+ === Bugfixes
4
+ * hard tabs crazy indentation for pystrings in formatter (#55 Aslak Hellesøy)
5
+
1
6
  == 1.0.23 (2010-05-02)
2
7
 
3
8
  === Changed Features
data/VERSION.yml CHANGED
@@ -2,4 +2,4 @@
2
2
  :major: 1
3
3
  :minor: 0
4
4
  :build:
5
- :patch: 23
5
+ :patch: 24
data/ragel/lexer.c.rl.erb CHANGED
@@ -290,7 +290,7 @@ store_pystring_content(VALUE listener,
290
290
  VALUE con = ENCODED_STR_NEW(at, length);
291
291
  // Gherkin will crash gracefully if the string representation of start_col pushes the pattern past 32 characters
292
292
  char pat[32];
293
- snprintf(pat, 32, "^ {0,%d}", start_col);
293
+ snprintf(pat, 32, "^[\t ]{0,%d}", start_col);
294
294
  VALUE re = rb_reg_regcomp(rb_str_new2(pat));
295
295
  VALUE re2 = rb_reg_regcomp(rb_str_new2("\r\\Z"));
296
296
  VALUE unescape_escaped_quotes = rb_reg_regcomp(rb_str_new2("\\\\\"\\\\\"\\\\\""));
@@ -29,7 +29,7 @@ public class <%= @i18n.underscored_iso_code.upcase %> implements Lexer {
29
29
  }
30
30
 
31
31
  action store_pystring_content {
32
- String con = unindent(startCol, substring(data, contentStart, nextKeywordStart-1).replaceFirst("(\\r?\\n)?( )*\\Z", "").replaceAll("\\\\\"\\\\\"\\\\\"", "\"\"\""));
32
+ String con = unindent(startCol, substring(data, contentStart, nextKeywordStart-1).replaceFirst("(\\r?\\n)?([\\t ])*\\Z", "").replaceAll("\\\\\"\\\\\"\\\\\"", "\"\"\""));
33
33
  listener.pyString(con, currentLine);
34
34
  }
35
35
 
@@ -198,7 +198,7 @@ public class <%= @i18n.underscored_iso_code.upcase %> implements Lexer {
198
198
  }
199
199
 
200
200
  private String unindent(int startCol, String text) {
201
- return Pattern.compile("^ {0," + startCol + "}", Pattern.MULTILINE).matcher(text).replaceAll("");
201
+ return Pattern.compile("^[\t ]{0," + startCol + "}", Pattern.MULTILINE).matcher(text).replaceAll("");
202
202
  }
203
203
 
204
204
  private String currentLineContent(byte[] data, int lastNewline) {
@@ -21,7 +21,7 @@ module Gherkin
21
21
  }
22
22
 
23
23
  action store_pystring_content {
24
- con = unindent(@start_col, data[@content_start...@next_keyword_start-1].utf8_pack("c*").sub(/(\r?\n)?( )*\Z/, '').gsub(/\\"\\"\\"/, '"""'))
24
+ con = unindent(@start_col, utf8_pack(data[@content_start...@next_keyword_start-1]).sub(/(\r?\n)?([\t ])*\Z/, '').gsub(/\\"\\"\\"/, '"""'))
25
25
  @listener.py_string(con, @current_line)
26
26
  }
27
27
 
@@ -56,18 +56,18 @@ module Gherkin
56
56
  }
57
57
 
58
58
  action store_step_content {
59
- con = data[@content_start...p].utf8_pack("c*").strip
59
+ con = utf8_pack(data[@content_start...p]).strip
60
60
  @listener.step(@keyword, con, @current_line)
61
61
  }
62
62
 
63
63
  action store_comment_content {
64
- con = data[@content_start...p].utf8_pack("c*").strip
64
+ con = utf8_pack(data[@content_start...p]).strip
65
65
  @listener.comment(con, @line_number)
66
66
  @keyword_start = nil
67
67
  }
68
68
 
69
69
  action store_tag_content {
70
- con = data[@content_start...p].utf8_pack("c*").strip
70
+ con = utf8_pack(data[@content_start...p]).strip
71
71
  @listener.tag(con, @current_line)
72
72
  @keyword_start = nil
73
73
  }
@@ -85,7 +85,7 @@ module Gherkin
85
85
  }
86
86
 
87
87
  action end_keyword {
88
- @keyword = data[@keyword_start...p].utf8_pack("c*").sub(/:$/,'')
88
+ @keyword = utf8_pack(data[@keyword_start...p]).sub(/:$/,'')
89
89
  @keyword_start = nil
90
90
  }
91
91
 
@@ -104,7 +104,7 @@ module Gherkin
104
104
  }
105
105
 
106
106
  action store_cell_content {
107
- con = data[@content_start...p].utf8_pack("c*").strip
107
+ con = utf8_pack(data[@content_start...p]).strip
108
108
  current_row << con
109
109
  }
110
110
 
@@ -153,18 +153,22 @@ module Gherkin
153
153
  end
154
154
 
155
155
  def unindent(startcol, text)
156
- text.gsub(/^ {0,#{startcol}}/, "")
156
+ text.gsub(/^[\t ]{0,#{startcol}}/, "")
157
157
  end
158
158
 
159
159
  def store_keyword_content(event, data, p, eof)
160
160
  end_point = (!@next_keyword_start or (p == eof)) ? p : @next_keyword_start
161
- con = yield data[@content_start...end_point].utf8_pack("c*")
161
+ con = yield utf8_pack(data[@content_start...end_point])
162
162
  @listener.send(event, @keyword, con, @current_line)
163
163
  end
164
164
 
165
165
  def current_line_content(data, p)
166
166
  rest = data[@last_newline..-1]
167
- rest[0..rest.index(10)||-1].utf8_pack("c*").strip
167
+ utf8_pack(rest[0..rest.index(10)||-1]).strip
168
+ end
169
+
170
+ def utf8_pack(array)
171
+ (RUBY_VERSION =~ /^1\.9/) ? array.pack("c*").force_encoding("UTF-8") : array.pack("c*")
168
172
  end
169
173
  end
170
174
  end
@@ -13,15 +13,17 @@ module Gherkin
13
13
  actual.should == s
14
14
  end
15
15
 
16
- def assert_pretty(text)
17
- io = StringIO.new
18
- l = PrettyFormatter.new(io, true)
19
- parser = Gherkin::Parser::Parser.new(l, true, "root")
20
- lexer = Gherkin::I18nLexer.new(parser, true)
21
- lexer.scan(text)
22
- io.rewind
23
- actual = io.read
24
- actual.should == text
16
+ def assert_pretty(input, output=input)
17
+ [true, false].each do |force_ruby|
18
+ io = StringIO.new
19
+ l = PrettyFormatter.new(io, true)
20
+ parser = Gherkin::Parser::Parser.new(l, true, "root")
21
+ lexer = Gherkin::I18nLexer.new(parser, force_ruby)
22
+ lexer.scan(input)
23
+ io.rewind
24
+ actual = io.read
25
+ actual.should == output
26
+ end
25
27
  end
26
28
 
27
29
  before do
@@ -142,6 +144,10 @@ Feature: Feature Description
142
144
  | Bed | They | are tired |
143
145
  })
144
146
  end
147
+
148
+ it "should preserve tabs" do
149
+ assert_pretty(IO.read(File.dirname(__FILE__) + '/tabs.feature'), IO.read(File.dirname(__FILE__) + '/spaces.feature'))
150
+ end
145
151
  end
146
152
  end
147
153
  end
@@ -0,0 +1,9 @@
1
+ Feature: Adding
2
+
3
+ Scenario: Add two numbers
4
+ Given the following input:
5
+ """
6
+ hello
7
+ """
8
+ When the calculator is run
9
+ Then the output should be 4
@@ -0,0 +1,9 @@
1
+ Feature: Adding
2
+
3
+ Scenario: Add two numbers
4
+ Given the following input:
5
+ """
6
+ hello
7
+ """
8
+ When the calculator is run
9
+ Then the output should be 4
data/tasks/compile.rake CHANGED
@@ -21,7 +21,7 @@ file 'lib/gherkin.jar' => Dir['java/src/main/java/**/*.java'] do
21
21
  end
22
22
 
23
23
  rl_langs = ENV['RL_LANGS'] ? ENV['RL_LANGS'].split(',') : []
24
- langs = Gherkin::I18n.all.select { |lang| rl_langs.empty? || rl_langs.include?(lang.key) }
24
+ langs = Gherkin::I18n.all.select { |lang| rl_langs.empty? || rl_langs.include?(lang.iso_code) }
25
25
 
26
26
  langs.each do |i18n|
27
27
  java = RagelTask.new('java', i18n)
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 1
7
7
  - 0
8
- - 23
9
- version: 1.0.23
8
+ - 24
9
+ version: 1.0.24
10
10
  platform: java
11
11
  authors:
12
12
  - Mike Sassak
@@ -99,7 +99,6 @@ files:
99
99
  - lib/gherkin.rb
100
100
  - lib/gherkin/c_lexer.rb
101
101
  - lib/gherkin/cli/main.rb
102
- - lib/gherkin/core_ext/array.rb
103
102
  - lib/gherkin/csharp_lexer.rb
104
103
  - lib/gherkin/formatter/argument.rb
105
104
  - lib/gherkin/formatter/colors.rb
@@ -145,6 +144,8 @@ files:
145
144
  - spec/gherkin/formatter/argument_spec.rb
146
145
  - spec/gherkin/formatter/colors_spec.rb
147
146
  - spec/gherkin/formatter/pretty_formatter_spec.rb
147
+ - spec/gherkin/formatter/spaces.feature
148
+ - spec/gherkin/formatter/tabs.feature
148
149
  - spec/gherkin/i18n_lexer_spec.rb
149
150
  - spec/gherkin/i18n_spec.rb
150
151
  - spec/gherkin/java_lexer_spec.rb
@@ -1,5 +0,0 @@
1
- class Array
2
- def utf8_pack(fmt)
3
- (RUBY_VERSION =~ /^1\.9/) ? pack(fmt).force_encoding("UTF-8") : pack(fmt)
4
- end
5
- end