gherkin 1.0.3-i386-mswin32 → 1.0.4-i386-mswin32

Sign up to get free protection for your applications and to get access to all the features.
Files changed (58) hide show
  1. data/History.txt +15 -6
  2. data/README.rdoc +15 -0
  3. data/Rakefile +1 -0
  4. data/VERSION.yml +1 -1
  5. data/features/step_definitions/gherkin_steps.rb +1 -1
  6. data/features/step_definitions/{pretty_printer_steps.rb → pretty_listener_step.rb} +2 -2
  7. data/gherkin.gemspec +24 -35
  8. data/java/Gherkin.iml +8 -14
  9. data/java/src/{gherkin → main/java/gherkin}/lexer/.gitignore +0 -0
  10. data/lib/gherkin.rb +1 -1
  11. data/lib/gherkin/c_lexer.rb +2 -2
  12. data/lib/gherkin/{format → formatter}/argument.rb +1 -1
  13. data/lib/gherkin/{tools → formatter}/colors.rb +1 -1
  14. data/lib/gherkin/{format → formatter}/monochrome_format.rb +1 -1
  15. data/lib/gherkin/{tools → formatter}/pretty_listener.rb +8 -9
  16. data/lib/gherkin/i18n.rb +27 -5
  17. data/lib/gherkin/i18n_lexer.rb +18 -44
  18. data/lib/gherkin/parser/filter_listener.rb +191 -0
  19. data/lib/gherkin/parser/parser.rb +142 -0
  20. data/lib/gherkin/parser/sexp.rb +45 -0
  21. data/lib/gherkin/parser/tag_expression.rb +46 -0
  22. data/lib/gherkin/rb_lexer.rb +2 -2
  23. data/ragel/lexer_common.rl.erb +1 -1
  24. data/spec/gherkin/{format → formatter}/argument_spec.rb +2 -2
  25. data/spec/gherkin/{tools → formatter}/colors_spec.rb +2 -2
  26. data/spec/gherkin/{tools → formatter}/pretty_listener_spec.rb +5 -5
  27. data/spec/gherkin/i18n_lexer_spec.rb +3 -3
  28. data/spec/gherkin/parser/filter_listener_spec.rb +363 -0
  29. data/spec/gherkin/parser/parser_spec.rb +35 -0
  30. data/spec/gherkin/parser/tag_expression_spec.rb +120 -0
  31. data/spec/gherkin/rb_lexer_spec.rb +0 -1
  32. data/spec/gherkin/sexp_recorder.rb +3 -3
  33. data/spec/gherkin/shared/lexer_spec.rb +19 -19
  34. data/spec/gherkin/shared/tags_spec.rb +4 -4
  35. data/tasks/bench.rake +2 -2
  36. data/tasks/compile.rake +1 -1
  37. data/tasks/ragel_task.rb +1 -1
  38. metadata +25 -36
  39. data/java/build.xml +0 -16
  40. data/java/src/gherkin/FixJava.java +0 -37
  41. data/java/src/gherkin/I18nLexer.java +0 -48
  42. data/java/src/gherkin/Lexer.java +0 -5
  43. data/java/src/gherkin/LexingError.java +0 -7
  44. data/java/src/gherkin/Listener.java +0 -29
  45. data/java/src/gherkin/Main.java +0 -17
  46. data/java/src/gherkin/ParseError.java +0 -22
  47. data/java/src/gherkin/Parser.java +0 -191
  48. data/java/src/gherkin/formatter/Argument.java +0 -39
  49. data/java/src/gherkin/formatter/ArgumentFormat.java +0 -17
  50. data/java/src/gherkin/formatter/Colors.java +0 -7
  51. data/java/src/gherkin/formatter/Formatter.java +0 -15
  52. data/java/src/gherkin/formatter/PrettyFormatter.java +0 -219
  53. data/java/src/gherkin/parser/StateMachineReader.java +0 -67
  54. data/java/test/gherkin/formatter/ArgumentTest.java +0 -17
  55. data/lib/gherkin/lexer.rb +0 -35
  56. data/lib/gherkin/parser.rb +0 -19
  57. data/lib/gherkin/rb_parser.rb +0 -125
  58. data/spec/gherkin/parser_spec.rb +0 -33
@@ -0,0 +1,120 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
2
+ require 'gherkin/parser/tag_expression'
3
+
4
+ module Gherkin
5
+ module Parser
6
+ describe TagExpression do
7
+ context "no tags" do
8
+ before(:each) do
9
+ @e = TagExpression.new
10
+ end
11
+
12
+ it "should match @foo" do
13
+ @e.eval('@foo').should == true
14
+ end
15
+
16
+ it "should match empty tags" do
17
+ @e.eval().should == true
18
+ end
19
+ end
20
+
21
+ context "@foo" do
22
+ before(:each) do
23
+ @e = TagExpression.new('@foo')
24
+ end
25
+
26
+ it "should match @foo" do
27
+ @e.eval('@foo').should == true
28
+ end
29
+
30
+ it "should not match @bar" do
31
+ @e.eval('@bar').should == false
32
+ end
33
+ end
34
+
35
+ context "!@foo" do
36
+ before(:each) do
37
+ @e = TagExpression.new('~@foo')
38
+ end
39
+
40
+ it "should match @bar" do
41
+ @e.eval('@bar').should == true
42
+ end
43
+
44
+ it "should not match @foo" do
45
+ @e.eval('@foo').should == false
46
+ end
47
+ end
48
+
49
+ context "@foo || @bar" do
50
+ before(:each) do
51
+ @e = TagExpression.new('@foo,@bar')
52
+ end
53
+
54
+ it "should match @foo" do
55
+ @e.eval('@foo').should == true
56
+ end
57
+
58
+ it "should match @bar" do
59
+ @e.eval('@bar').should == true
60
+ end
61
+
62
+ it "should not match @zap" do
63
+ @e.eval('@zap').should == false
64
+ end
65
+ end
66
+
67
+ context "(@foo || @bar) && !@zap" do
68
+ before(:each) do
69
+ @e = TagExpression.new('@foo,@bar', '~@zap')
70
+ end
71
+
72
+ it "should match @foo" do
73
+ @e.eval('@foo').should == true
74
+ end
75
+
76
+ it "should not match @foo @zap" do
77
+ @e.eval('@foo', '@zap').should == false
78
+ end
79
+ end
80
+
81
+ context "(@foo:3 || !@bar:4) && @zap:5" do
82
+ before(:each) do
83
+ @e = TagExpression.new('@foo:3,~@bar','@zap:5')
84
+ end
85
+
86
+ it "should count tags for positive tags" do
87
+ @e.limits.should == {'@foo' => 3, '@zap' => 5}
88
+ end
89
+
90
+ it "should match @foo @zap" do
91
+ @e.eval('@foo', '@zap').should == true
92
+ end
93
+ end
94
+
95
+ context "Parsing '@foo:3,~@bar', '@zap:5'" do
96
+ before(:each) do
97
+ @e = TagExpression.new(' @foo:3 , ~@bar ', ' @zap:5 ')
98
+ end
99
+
100
+ it "should split and trim" do
101
+ @e.__send__(:ruby_expression).should == "(!vars['@bar']||vars['@foo'])&&(vars['@zap'])"
102
+ end
103
+
104
+ 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
116
+ end
117
+ end
118
+ end
119
+ end
120
+ end
@@ -1,6 +1,5 @@
1
1
  #encoding: utf-8
2
2
  require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
3
- require 'gherkin/rb_lexer'
4
3
  require 'gherkin/rb_lexer/en'
5
4
 
6
5
  module Gherkin
@@ -4,9 +4,9 @@ module Gherkin
4
4
  @sexps = []
5
5
  end
6
6
 
7
- def method_missing(m, *args)
8
- args[0] = args[0].map{|cell| cell} if m == :row
9
- @sexps << [m] + args
7
+ def method_missing(event, *args)
8
+ args[0] = args[0].to_a if event == :row # Special JRuby handling
9
+ @sexps << [event] + args
10
10
  end
11
11
 
12
12
  def to_sexp
@@ -56,7 +56,7 @@ module Gherkin
56
56
  @listener.to_sexp.should == [
57
57
  [:feature, "Feature", "hi", 1],
58
58
  [:scenario, "Scenario", "test", 2],
59
- [:tag, "hello", 4],
59
+ [:tag, "@hello", 4],
60
60
  [:scenario, "Scenario", "another", 5],
61
61
  [:eof]
62
62
  ]
@@ -404,16 +404,16 @@ Given I am a step
404
404
  scan_file("simple_with_tags.feature")
405
405
  @listener.to_sexp.should == [
406
406
  [:comment, "# FC", 1],
407
- [:tag, "ft",2],
407
+ [:tag, "@ft",2],
408
408
  [:feature, "Feature", "hi", 3],
409
- [:tag, "st1", 5],
410
- [:tag, "st2", 5],
409
+ [:tag, "@st1", 5],
410
+ [:tag, "@st2", 5],
411
411
  [:scenario, "Scenario", "First", 6],
412
412
  [:step, "Given ", "Pepper", 7],
413
- [:tag, "st3", 9],
414
- [:tag, "st4", 10],
415
- [:tag, "ST5", 10],
416
- [:tag, "#^%&ST6**!", 10],
413
+ [:tag, "@st3", 9],
414
+ [:tag, "@st4", 10],
415
+ [:tag, "@ST5", 10],
416
+ [:tag, "@#^%&ST6**!", 10],
417
417
  [:scenario, "Scenario", "Second", 11],
418
418
  [:eof]
419
419
  ]
@@ -427,7 +427,7 @@ Given I am a step
427
427
  [:feature, "Feature", "Logging in\nSo that I can be myself", 1],
428
428
  [:comment, "# Comment", 3],
429
429
  [:scenario, "Scenario", "Anonymous user can get a login form.\nScenery here", 4],
430
- [:tag, "tag", 7],
430
+ [:tag, "@tag", 7],
431
431
  [:scenario, "Scenario", "Another one", 8],
432
432
  [:eof]
433
433
  ]
@@ -440,20 +440,20 @@ Given I am a step
440
440
  @listener.to_sexp.should == [
441
441
  [:comment, "#Comment on line 1", 1],
442
442
  [:comment, "#Comment on line 2", 2],
443
- [:tag, "tag1", 3],
444
- [:tag, "tag2", 3],
443
+ [:tag, "@tag1", 3],
444
+ [:tag, "@tag2", 3],
445
445
  [:feature, "Feature", "Feature Text\nIn order to test multiline forms\nAs a ragel writer\nI need to check for complex combinations", 4],
446
446
  [:comment, "#Comment on line 9", 9],
447
447
  [:comment, "#Comment on line 11", 11],
448
448
  [:background, "Background", "", 13],
449
449
  [:step, "Given ", "this is a background step", 14],
450
450
  [:step, "And ", "this is another one", 15],
451
- [:tag, "tag3", 17],
452
- [:tag, "tag4", 17],
451
+ [:tag, "@tag3", 17],
452
+ [:tag, "@tag4", 17],
453
453
  [:scenario, "Scenario", "Reading a Scenario", 18],
454
454
  [:step, "Given ", "there is a step", 19],
455
455
  [:step, "But ", "not another step", 20],
456
- [:tag, "tag3", 22],
456
+ [:tag, "@tag3", 22],
457
457
  [:scenario, "Scenario", "Reading a second scenario\nWith two lines of text", 23],
458
458
  [:comment, "#Comment on line 24", 25],
459
459
  [:step, "Given ", "a third step with a table", 26],
@@ -484,20 +484,20 @@ Given I am a step
484
484
  @listener.to_sexp.should == [
485
485
  [:comment, "#Comment on line 1", 1],
486
486
  [:comment, "#Comment on line 2", 2],
487
- [:tag, "tag1", 3],
488
- [:tag, "tag2", 3],
487
+ [:tag, "@tag1", 3],
488
+ [:tag, "@tag2", 3],
489
489
  [:feature, "Feature", "Feature Text\r\nIn order to test multiline forms\r\nAs a ragel writer\r\nI need to check for complex combinations", 4],
490
490
  [:comment, "#Comment on line 9", 9],
491
491
  [:comment, "#Comment on line 11", 11],
492
492
  [:background, "Background", "", 13],
493
493
  [:step, "Given ", "this is a background step", 14],
494
494
  [:step, "And ", "this is another one", 15],
495
- [:tag, "tag3", 17],
496
- [:tag, "tag4", 17],
495
+ [:tag, "@tag3", 17],
496
+ [:tag, "@tag4", 17],
497
497
  [:scenario, "Scenario", "Reading a Scenario", 18],
498
498
  [:step, "Given ", "there is a step", 19],
499
499
  [:step, "But ", "not another step", 20],
500
- [:tag, "tag3", 22],
500
+ [:tag, "@tag3", 22],
501
501
  [:scenario, "Scenario", "Reading a second scenario\r\nWith two lines of text", 23],
502
502
  [:comment, "#Comment on line 24", 25],
503
503
  [:step, "Given ", "a third step with a table", 26],
@@ -5,7 +5,7 @@ module Gherkin
5
5
  module Lexer
6
6
  shared_examples_for "a Gherkin lexer lexing tags" do
7
7
  it "should lex a single tag" do
8
- @listener.should_receive(:tag).with("dog", 1)
8
+ @listener.should_receive(:tag).with("@dog", 1)
9
9
  @lexer.scan("@dog\n")
10
10
  end
11
11
 
@@ -15,13 +15,13 @@ module Gherkin
15
15
  end
16
16
 
17
17
  it "should lex UTF-8 tags" do
18
- @listener.should_receive(:tag).with("シナリオテンプレート", 1)
18
+ @listener.should_receive(:tag).with("@シナリオテンプレート", 1)
19
19
  @lexer.scan("@シナリオテンプレート\n")
20
20
  end
21
21
 
22
22
  it "should lex mixed tags" do
23
- @listener.should_receive(:tag).with("wip", 1).ordered
24
- @listener.should_receive(:tag).with("Значения", 1).ordered
23
+ @listener.should_receive(:tag).with("@wip", 1).ordered
24
+ @listener.should_receive(:tag).with("@Значения", 1).ordered
25
25
  @lexer.scan("@wip @Значения\n")
26
26
  end
27
27
 
data/tasks/bench.rake CHANGED
@@ -106,11 +106,11 @@ class Benchmarker
106
106
 
107
107
  def run_rb_gherkin
108
108
  require 'gherkin'
109
- require 'gherkin/rb_lexer'
109
+ require 'gherkin/rb_lexer/en'
110
110
  require 'null_listener'
111
111
  @features.each do |feature|
112
112
  parser = Gherkin::Parser.new(NullListener.new, true, "root")
113
- lexer = Gherkin::RbLexer['en'].new(parser)
113
+ lexer = Gherkin::RbLexer::En.new(parser)
114
114
  lexer.scan(File.read(feature))
115
115
  end
116
116
  end
data/tasks/compile.rake CHANGED
@@ -16,7 +16,7 @@ CLEAN.include [
16
16
 
17
17
  desc "Compile the Java extensions"
18
18
  task :jar do
19
- sh("ant -f java/build.xml")
19
+ sh("mvn -f java/pom.xml package")
20
20
  end
21
21
 
22
22
  namespace :dotnet do
data/tasks/ragel_task.rb CHANGED
@@ -28,7 +28,7 @@ class RagelTask
28
28
  def target
29
29
  {
30
30
  'c' => "ext/gherkin_lexer_#{@i18n.sanitized_key}/gherkin_lexer_#{@i18n.sanitized_key}.c",
31
- 'java' => "java/src/gherkin/lexer/#{@i18n.sanitized_key.capitalize}.java",
31
+ 'java' => "java/src/main/java/gherkin/lexer/#{@i18n.sanitized_key.capitalize}.java",
32
32
  'rb' => "lib/gherkin/rb_lexer/#{@i18n.sanitized_key}.rb",
33
33
  'csharp' => "tmp/#{@i18n.sanitized_key}.cs"
34
34
  }[@lang]
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 1
7
7
  - 0
8
- - 3
9
- version: 1.0.3
8
+ - 4
9
+ version: 1.0.4
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-03-30 00:00:00 +02:00
19
+ date: 2010-04-07 00:00:00 +02:00
20
20
  default_executable: gherkin
21
21
  dependencies:
22
22
  - !ruby/object:Gem::Dependency
@@ -114,53 +114,38 @@ files:
114
114
  - features/parser_with_native_lexer.feature
115
115
  - features/pretty_printer.feature
116
116
  - features/step_definitions/gherkin_steps.rb
117
- - features/step_definitions/pretty_printer_steps.rb
117
+ - features/step_definitions/pretty_listener_step.rb
118
118
  - features/steps_parser.feature
119
119
  - features/support/env.rb
120
120
  - gherkin.gemspec
121
121
  - java/.gitignore
122
122
  - java/Gherkin.iml
123
- - java/build.xml
124
- - java/src/gherkin/FixJava.java
125
- - java/src/gherkin/I18nLexer.java
126
- - java/src/gherkin/Lexer.java
127
- - java/src/gherkin/LexingError.java
128
- - java/src/gherkin/Listener.java
129
- - java/src/gherkin/Main.java
130
- - java/src/gherkin/ParseError.java
131
- - java/src/gherkin/Parser.java
132
- - java/src/gherkin/formatter/Argument.java
133
- - java/src/gherkin/formatter/ArgumentFormat.java
134
- - java/src/gherkin/formatter/Colors.java
135
- - java/src/gherkin/formatter/Formatter.java
136
- - java/src/gherkin/formatter/PrettyFormatter.java
137
- - java/src/gherkin/lexer/.gitignore
138
- - java/src/gherkin/parser/StateMachineReader.java
139
- - java/test/gherkin/formatter/ArgumentTest.java
123
+ - java/src/main/java/gherkin/lexer/.gitignore
140
124
  - lib/.gitignore
141
125
  - lib/gherkin.rb
142
126
  - lib/gherkin/c_lexer.rb
143
127
  - lib/gherkin/cli/main.rb
144
128
  - lib/gherkin/core_ext/array.rb
145
129
  - lib/gherkin/csharp_lexer.rb
146
- - lib/gherkin/format/argument.rb
147
- - lib/gherkin/format/monochrome_format.rb
130
+ - lib/gherkin/formatter/argument.rb
131
+ - lib/gherkin/formatter/colors.rb
132
+ - lib/gherkin/formatter/monochrome_format.rb
133
+ - lib/gherkin/formatter/pretty_listener.rb
148
134
  - lib/gherkin/i18n.rb
149
135
  - lib/gherkin/i18n.yml
150
136
  - lib/gherkin/i18n_lexer.rb
151
- - lib/gherkin/lexer.rb
152
- - lib/gherkin/parser.rb
137
+ - lib/gherkin/parser/filter_listener.rb
153
138
  - lib/gherkin/parser/meta.txt
139
+ - lib/gherkin/parser/parser.rb
154
140
  - lib/gherkin/parser/root.txt
141
+ - lib/gherkin/parser/sexp.rb
155
142
  - lib/gherkin/parser/steps.txt
143
+ - lib/gherkin/parser/tag_expression.rb
156
144
  - lib/gherkin/rb_lexer.rb
157
145
  - lib/gherkin/rb_lexer/.gitignore
158
146
  - lib/gherkin/rb_lexer/README.rdoc
159
- - lib/gherkin/rb_parser.rb
160
147
  - lib/gherkin/tools.rb
161
- - lib/gherkin/tools/colors.rb
162
148
  - lib/gherkin/tools/files.rb
163
- - lib/gherkin/tools/pretty_listener.rb
164
149
  - lib/gherkin/tools/reformat.rb
165
150
  - lib/gherkin/tools/stats.rb
166
151
  - lib/gherkin/tools/stats_listener.rb
@@ -183,19 +168,21 @@ files:
183
168
  - spec/gherkin/fixtures/simple.feature
184
169
  - spec/gherkin/fixtures/simple_with_comments.feature
185
170
  - spec/gherkin/fixtures/simple_with_tags.feature
186
- - spec/gherkin/format/argument_spec.rb
171
+ - spec/gherkin/formatter/argument_spec.rb
172
+ - spec/gherkin/formatter/colors_spec.rb
173
+ - spec/gherkin/formatter/pretty_listener_spec.rb
187
174
  - spec/gherkin/i18n_lexer_spec.rb
188
175
  - spec/gherkin/i18n_spec.rb
189
176
  - spec/gherkin/java_lexer_spec.rb
190
- - spec/gherkin/parser_spec.rb
177
+ - spec/gherkin/parser/filter_listener_spec.rb
178
+ - spec/gherkin/parser/parser_spec.rb
179
+ - spec/gherkin/parser/tag_expression_spec.rb
191
180
  - spec/gherkin/rb_lexer_spec.rb
192
181
  - spec/gherkin/sexp_recorder.rb
193
182
  - spec/gherkin/shared/lexer_spec.rb
194
183
  - spec/gherkin/shared/py_string_spec.rb
195
184
  - spec/gherkin/shared/row_spec.rb
196
185
  - spec/gherkin/shared/tags_spec.rb
197
- - spec/gherkin/tools/colors_spec.rb
198
- - spec/gherkin/tools/pretty_listener_spec.rb
199
186
  - spec/spec_helper.rb
200
187
  - tasks/bench.rake
201
188
  - tasks/bench/feature_builder.rb
@@ -239,17 +226,19 @@ summary: Fast Gherkin lexer/parser
239
226
  test_files:
240
227
  - spec/gherkin/c_lexer_spec.rb
241
228
  - spec/gherkin/csharp_lexer_spec.rb
242
- - spec/gherkin/format/argument_spec.rb
229
+ - spec/gherkin/formatter/argument_spec.rb
230
+ - spec/gherkin/formatter/colors_spec.rb
231
+ - spec/gherkin/formatter/pretty_listener_spec.rb
243
232
  - spec/gherkin/i18n_lexer_spec.rb
244
233
  - spec/gherkin/i18n_spec.rb
245
234
  - spec/gherkin/java_lexer_spec.rb
246
- - spec/gherkin/parser_spec.rb
235
+ - spec/gherkin/parser/filter_listener_spec.rb
236
+ - spec/gherkin/parser/parser_spec.rb
237
+ - spec/gherkin/parser/tag_expression_spec.rb
247
238
  - spec/gherkin/rb_lexer_spec.rb
248
239
  - spec/gherkin/sexp_recorder.rb
249
240
  - spec/gherkin/shared/lexer_spec.rb
250
241
  - spec/gherkin/shared/py_string_spec.rb
251
242
  - spec/gherkin/shared/row_spec.rb
252
243
  - spec/gherkin/shared/tags_spec.rb
253
- - spec/gherkin/tools/colors_spec.rb
254
- - spec/gherkin/tools/pretty_listener_spec.rb
255
244
  - spec/spec_helper.rb
data/java/build.xml DELETED
@@ -1,16 +0,0 @@
1
- <project name="Gherkin" default="jar" basedir=".">
2
- <target name="compile" description="Compile">
3
- <mkdir dir="${basedir}/target/classes"/>
4
- <javac srcdir="src" destdir="target/classes" debug="on"/>
5
- </target>
6
-
7
- <target name="jar" description="Jar" depends="compile">
8
- <jar destfile="${basedir}/../lib/gherkin.jar">
9
- <fileset dir="${basedir}/target/classes" />
10
- <fileset dir="${basedir}/../lib" includes="gherkin/parser/*.txt" />
11
- <manifest>
12
- <attribute name="Main-Class" value="gherkin.Main" />
13
- </manifest>
14
- </jar>
15
- </target>
16
- </project>
@@ -1,37 +0,0 @@
1
- package gherkin;
2
-
3
- import java.io.IOException;
4
- import java.io.InputStreamReader;
5
- import java.io.Reader;
6
- import java.util.List;
7
-
8
- public class FixJava {
9
- public static String join(List<String> strings, String separator) {
10
- StringBuilder sb = new StringBuilder();
11
- int i = 0;
12
- for (String s : strings) {
13
- if (i != 0) sb.append(separator);
14
- sb.append(s);
15
- i++;
16
- }
17
- return sb.toString();
18
- }
19
-
20
- public static String readResource(String filePath) throws IOException {
21
- Reader reader = new InputStreamReader(FixJava.class.getResourceAsStream(filePath));
22
- return readReader(reader);
23
- }
24
-
25
- public static String readReader(Reader reader) throws IOException {
26
- final char[] buffer = new char[0x10000];
27
- StringBuilder sb = new StringBuilder();
28
- int read;
29
- do {
30
- read = reader.read(buffer, 0, buffer.length);
31
- if (read > 0) {
32
- sb.append(buffer, 0, read);
33
- }
34
- } while (read >= 0);
35
- return sb.toString();
36
- }
37
- }