anbt-sql-formatter 0.0.5 → 0.0.6

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 06c0d1af78c569f0eb6c74286ade60edd1aaeca8
4
- data.tar.gz: f1366c1c4e7a1769c5384ad2ff102702499466e5
2
+ SHA256:
3
+ metadata.gz: 533c8ba946b0b41bb3e9b56631b9e4fcbf7fd8e643b6c0875c1a3d1b2f8f25c8
4
+ data.tar.gz: e74a08b3d979b1cab4d998533c8ed6167cfe703ee75288da4e45d31c25e91d41
5
5
  SHA512:
6
- metadata.gz: 0e12afe4467dba91c3ac4f18f39594b33d3a73f4008b37e46fa22f8f51dc6041b6c470c83ee4b22fdfeffdda7db12a41d9a3c96239e375c803df6390e47c2fe4
7
- data.tar.gz: 44e782498886cebb11e7b49a087b35d46d30364d10709efc20f1dd6f13ad790b087f41e34f40083f7a4d01328be21aca18f47b04a1aad0a6e64cb77107c6b42b
6
+ metadata.gz: cfd6fdc3fc8621957778f559464c7ab863cc5665b0ec084cbf755010ee6fd1699e7f3ad1952bc85d43d6d1fb233eb1b49858935d3c67fe1a7f4b9c4b8c20e476
7
+ data.tar.gz: 9b8ddfe422d4fb89f381751c95517ab8252a9abd6a915df228886deffec4d478c95f9983a356d681ac12ea8eb035cdb21424816074d4980547897a03c5328e7d
data/.gitignore CHANGED
@@ -2,3 +2,6 @@
2
2
  .bundle
3
3
  Gemfile.lock
4
4
  pkg/*
5
+
6
+ # Emacs
7
+ *~
@@ -1,3 +1,8 @@
1
+ # 0.0.6 (2018-03-31)
2
+
3
+ No breaking changes.
4
+
5
+
1
6
  # 0.0.5 (2016-11-29)
2
7
 
3
8
  No breaking changes.
@@ -57,13 +57,13 @@ class AnbtSql
57
57
 
58
58
  statements = split_to_statements(tokens)
59
59
 
60
- statements = statements.map{|tokens|
61
- format_list(tokens)
60
+ statements = statements.map{|inner_tokens|
61
+ format_list(inner_tokens)
62
62
  }
63
63
 
64
64
  # 変換結果を文字列に戻す。
65
- after = statements.map{|tokens|
66
- tokens.map{ |t| t.string }.join("")
65
+ after = statements.map{|inner_tokens|
66
+ inner_tokens.map{ |t| t.string }.join("")
67
67
  }.join("\n;\n\n").sub( /\n\n\Z/, "" )
68
68
 
69
69
  after += "\n" if is_sql_ends_with_new_line
@@ -175,6 +175,8 @@ class AnbtSql
175
175
  prev = AnbtSql::Token.new(AnbtSql::TokenConstants::SPACE,
176
176
  " ")
177
177
 
178
+ encounter_between = false
179
+
178
180
  index = 0
179
181
  # Length of tokens changes in loop!
180
182
  while index < tokens.size
@@ -337,8 +339,6 @@ class AnbtSql
337
339
  remove_symbol_side_space(tokens)
338
340
  concat_operator_for_oracle(tokens)
339
341
 
340
- encounter_between = false
341
-
342
342
  format_list_main_loop(tokens)
343
343
 
344
344
  special_treatment_for_parenthesis_with_one_element(tokens)
@@ -1,7 +1,7 @@
1
1
  module Anbt
2
2
  module Sql
3
3
  module Formatter
4
- VERSION = "0.0.5"
4
+ VERSION = "0.0.6"
5
5
  end
6
6
  end
7
7
  end
@@ -61,11 +61,9 @@ class TestCoarseTokenizer < Test::Unit::TestCase
61
61
  end
62
62
 
63
63
 
64
- def test_tokenize
65
- msg = "tokenize - "
66
-
64
+ def test_tokenize_1
67
65
  assert_equals(
68
- msg,
66
+ "tokenize 1",
69
67
  strip_indent(
70
68
  <<-EOB
71
69
  plain (aa)
@@ -77,10 +75,11 @@ class TestCoarseTokenizer < Test::Unit::TestCase
77
75
  EOB
78
76
  )))
79
77
  )
80
-
81
- ########
78
+ end
79
+
80
+ def test_tokenize_2
82
81
  assert_equals(
83
- msg,
82
+ "tokenize 2",
84
83
  strip_indent(
85
84
  <<-EOB
86
85
  plain (aa )
@@ -93,10 +92,11 @@ class TestCoarseTokenizer < Test::Unit::TestCase
93
92
  EOB
94
93
  )))
95
94
  )
95
+ end
96
96
 
97
- ########
97
+ def test_tokenize_3
98
98
  assert_equals(
99
- msg,
99
+ "tokenize 3",
100
100
  strip_indent(
101
101
  <<-EOB
102
102
  plain (aa )
@@ -109,10 +109,11 @@ class TestCoarseTokenizer < Test::Unit::TestCase
109
109
  EOB
110
110
  )))
111
111
  )
112
+ end
112
113
 
113
- ########
114
+ def test_tokenize_4
114
115
  assert_equals(
115
- msg,
116
+ "tokenize 4",
116
117
  strip_indent(
117
118
  <<-EOB
118
119
  plain (aa )
@@ -127,10 +128,11 @@ class TestCoarseTokenizer < Test::Unit::TestCase
127
128
  EOB
128
129
  )))
129
130
  )
131
+ end
130
132
 
131
- ########
133
+ def test_tokenize_5
132
134
  assert_equals(
133
- msg,
135
+ "tokenize 5",
134
136
  strip_indent(
135
137
  <<-EOB
136
138
  plain (aa )
@@ -144,10 +146,11 @@ class TestCoarseTokenizer < Test::Unit::TestCase
144
146
  EOB
145
147
  )))
146
148
  )
149
+ end
147
150
 
148
- ########
151
+ def test_tokenize_6
149
152
  assert_equals(
150
- msg + "begin with multiline comment",
153
+ "tokenize - begin with multiline comment",
151
154
  strip_indent(
152
155
  <<-EOB
153
156
  comment_multi (/* bb */)
@@ -163,12 +166,9 @@ class TestCoarseTokenizer < Test::Unit::TestCase
163
166
  end
164
167
 
165
168
 
166
- def test_string_in_string
167
- msg = "string_in_string"
168
-
169
- ########
169
+ def test_string_in_string_1
170
170
  assert_equals(
171
- msg,
171
+ "string_in_string 1",
172
172
  strip_indent(
173
173
  <<-EOB
174
174
  quote_double ("aa'bb'cc")
@@ -180,10 +180,11 @@ class TestCoarseTokenizer < Test::Unit::TestCase
180
180
  EOB
181
181
  )))
182
182
  )
183
+ end
183
184
 
184
- ########
185
+ def test_string_in_string_2
185
186
  assert_equals(
186
- msg,
187
+ "string_in_string 2",
187
188
  strip_indent(
188
189
  <<-EOB
189
190
  quote_single ('aa"bb"cc')
@@ -198,12 +199,9 @@ class TestCoarseTokenizer < Test::Unit::TestCase
198
199
  end
199
200
 
200
201
 
201
- def test_comment_in_comment
202
- msg = "comment_in_comment - "
203
-
204
- ########
202
+ def test_comment_in_comment_1
205
203
  assert_equals(
206
- msg,
204
+ "comment_in_comment 1",
207
205
  strip_indent(
208
206
  <<-EOB
209
207
  comment_single (--a--b)
@@ -215,10 +213,11 @@ class TestCoarseTokenizer < Test::Unit::TestCase
215
213
  EOB
216
214
  )))
217
215
  )
216
+ end
218
217
 
219
- ########
218
+ def test_comment_in_comment_2
220
219
  assert_equals(
221
- msg,
220
+ "comment_in_comment 2",
222
221
  strip_indent(
223
222
  <<-EOB
224
223
  comment_single (-- aa /* bb */)
@@ -230,10 +229,11 @@ class TestCoarseTokenizer < Test::Unit::TestCase
230
229
  EOB
231
230
  )))
232
231
  )
232
+ end
233
233
 
234
- ########
234
+ def test_comment_in_comment_3
235
235
  assert_equals(
236
- msg,
236
+ "comment_in_comment 3",
237
237
  strip_indent(
238
238
  <<-EOB
239
239
  comment_multi (/* aa /* bb */)
@@ -245,10 +245,11 @@ class TestCoarseTokenizer < Test::Unit::TestCase
245
245
  EOB
246
246
  )))
247
247
  )
248
+ end
248
249
 
249
- ########
250
+ def test_comment_in_comment_4
250
251
  assert_equals(
251
- msg,
252
+ "comment_in_comment 4",
252
253
  strip_indent(
253
254
  <<-EOB
254
255
  comment_multi (/* aa -- bb */)
@@ -263,12 +264,9 @@ class TestCoarseTokenizer < Test::Unit::TestCase
263
264
  end
264
265
 
265
266
 
266
- def test_string_in_comment
267
- msg = "string_in_comment - "
268
-
269
- ########
267
+ def test_string_in_comment_1
270
268
  assert_equals(
271
- msg,
269
+ "string_in_comment 1",
272
270
  strip_indent(
273
271
  <<-EOB
274
272
  comment_single (-- aa "bb" cc)
@@ -280,10 +278,11 @@ class TestCoarseTokenizer < Test::Unit::TestCase
280
278
  EOB
281
279
  )))
282
280
  )
281
+ end
283
282
 
284
- ########
283
+ def test_string_in_comment_2
285
284
  assert_equals(
286
- msg,
285
+ "string_in_comment 2",
287
286
  strip_indent(
288
287
  <<-EOB
289
288
  comment_single (-- aa 'bb' cc)
@@ -295,10 +294,11 @@ class TestCoarseTokenizer < Test::Unit::TestCase
295
294
  EOB
296
295
  )))
297
296
  )
297
+ end
298
298
 
299
- ########
299
+ def test_string_in_comment_3
300
300
  assert_equals(
301
- msg,
301
+ "string_in_comment 3",
302
302
  strip_indent(
303
303
  <<-EOB
304
304
  comment_multi (/* aa "bb" cc */)
@@ -310,10 +310,11 @@ class TestCoarseTokenizer < Test::Unit::TestCase
310
310
  EOB
311
311
  )))
312
312
  )
313
+ end
313
314
 
314
- ########
315
+ def test_string_in_comment_4
315
316
  assert_equals(
316
- msg,
317
+ "string_in_comment 4",
317
318
  strip_indent(
318
319
  <<-EOB
319
320
  comment_multi (/* aa 'bb' cc */)
@@ -328,12 +329,9 @@ class TestCoarseTokenizer < Test::Unit::TestCase
328
329
  end
329
330
 
330
331
 
331
- def test_comment_in_string
332
- msg = "comment_in_string - "
333
-
334
- ########
332
+ def test_comment_in_string_1
335
333
  assert_equals(
336
- msg + "comment_single in quote_single",
334
+ "comment_in_string - comment_single in quote_single",
337
335
  strip_indent(
338
336
  <<-EOB
339
337
  quote_single ('aa--bb')
@@ -345,10 +343,11 @@ class TestCoarseTokenizer < Test::Unit::TestCase
345
343
  EOB
346
344
  )))
347
345
  )
346
+ end
348
347
 
349
- ########
348
+ def test_comment_in_string_2
350
349
  assert_equals(
351
- msg + "comment_single in quote_double",
350
+ "comment_in_string - comment_single in quote_double",
352
351
  strip_indent(
353
352
  <<-EOB
354
353
  quote_double ("aa--bb")
@@ -360,10 +359,11 @@ class TestCoarseTokenizer < Test::Unit::TestCase
360
359
  EOB
361
360
  )))
362
361
  )
362
+ end
363
363
 
364
- ########
364
+ def test_comment_in_string_3
365
365
  assert_equals(
366
- msg + "comment_multi in quote_double",
366
+ "comment_in_string - comment_multi in quote_double",
367
367
  strip_indent(
368
368
  <<-EOB
369
369
  quote_double ("aa /* bb */ cc")
@@ -375,10 +375,11 @@ class TestCoarseTokenizer < Test::Unit::TestCase
375
375
  EOB
376
376
  )))
377
377
  )
378
+ end
378
379
 
379
- ########
380
+ def test_comment_in_string_4
380
381
  assert_equals(
381
- msg + "comment_multi in quote_double",
382
+ "comment_in_string - comment_multi in quote_double",
382
383
  strip_indent(
383
384
  <<-EOB
384
385
  quote_single ('aa /* bb */ cc')
@@ -393,12 +394,9 @@ class TestCoarseTokenizer < Test::Unit::TestCase
393
394
  end
394
395
 
395
396
 
396
- def test_string_escape
397
- msg = "string_escape"
398
-
399
- ########
397
+ def test_string_escape_1
400
398
  assert_equals(
401
- msg,
399
+ "string_escape 1",
402
400
  strip_indent(
403
401
  <<-EOB
404
402
  quote_double ("_a_\\\\_b_\n_c_\\'_d_")
@@ -410,10 +408,11 @@ class TestCoarseTokenizer < Test::Unit::TestCase
410
408
  EOB
411
409
  )))
412
410
  )
411
+ end
413
412
 
414
- ########
413
+ def test_string_escape_2
415
414
  assert_equals(
416
- msg,
415
+ "string_escape 2",
417
416
  strip_indent(
418
417
  <<-EOB
419
418
  quote_single ('_a_\\\\_b_\n_c_\\'_d_')
@@ -425,10 +424,11 @@ class TestCoarseTokenizer < Test::Unit::TestCase
425
424
  EOB
426
425
  )))
427
426
  )
427
+ end
428
428
 
429
- ########
429
+ def test_string_escape_3
430
430
  assert_equals(
431
- msg,
431
+ "string_escape 3",
432
432
  strip_indent(
433
433
  <<-EOB
434
434
  quote_double ("_a_""_b_")
@@ -440,10 +440,11 @@ class TestCoarseTokenizer < Test::Unit::TestCase
440
440
  EOB
441
441
  )))
442
442
  )
443
+ end
443
444
 
444
- ########
445
+ def test_string_escape_4
445
446
  assert_equals(
446
- msg,
447
+ "string_escape 4",
447
448
  strip_indent(
448
449
  <<-EOB
449
450
  quote_single ('_a_''_b_')
@@ -498,8 +498,20 @@ class TestAnbtSqlFormatter < Test::Unit::TestCase
498
498
  @fmt.format("a;")
499
499
  )
500
500
  end
501
-
502
-
501
+
502
+ def test_format_between
503
+ assert_equals(
504
+ "should not add a new line to 'BETWEEN ... AND ...'",
505
+ strip_indent(
506
+ <<-EOB
507
+ BETWEEN 0 AND 1
508
+ EOB
509
+ ),
510
+ @fmt.format("between 0 and 1")
511
+ )
512
+ end
513
+
514
+
503
515
  def test_split_to_statements
504
516
  msg = "split_to_statements - "
505
517
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: anbt-sql-formatter
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - sonota88
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-11-29 00:00:00.000000000 Z
11
+ date: 2018-03-31 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: A tool for SQL formatting written in Ruby. Ruby port of Blanco SQL Formatter.
14
14
  email:
@@ -66,7 +66,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
66
66
  version: '0'
67
67
  requirements: []
68
68
  rubyforge_project: anbt-sql-formatter
69
- rubygems_version: 2.6.8
69
+ rubygems_version: 2.7.6
70
70
  signing_key:
71
71
  specification_version: 4
72
72
  summary: A tool for SQL formatting written in Ruby.