yaml-sort 2.2.0 → 2.2.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +16 -0
- data/lib/yaml/sort/parser.rb +99 -45
- data/lib/yaml/sort/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8fc2f27d56aec98cd2639b6751d584ef595133831e237de2424f9d4f4fef8495
|
4
|
+
data.tar.gz: 89e5a82b06b5458c5592c65e28b97916b6a357203e65ac058b5bc167423dba3c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e1bd41a83d2ddade59a115f681cb832d0761a7cc27deee193fb8c3aa711137508e288ce4fd736019e161184cf1257160d04b7088f51a4931c695fd9a5ec67ee3
|
7
|
+
data.tar.gz: 3d5f6d8359d14e62735bf7981a3c670c3156649ec4892f6eb6b4ef4c7019998f4940804795a34f5fad99f0fedd960a245af94fbb274d90fa5532e28da5370650
|
data/CHANGELOG.md
CHANGED
@@ -3,6 +3,22 @@ All notable changes to this project will be documented in this file.
|
|
3
3
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
|
4
4
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
5
5
|
|
6
|
+
## [v2.2.2](https://github.com/smortex/yaml-sort/tree/v2.2.2) (2023-01-06)
|
7
|
+
|
8
|
+
[Full Changelog](https://github.com/smortex/yaml-sort/compare/v2.2.1...v2.2.2)
|
9
|
+
|
10
|
+
**Fixed bugs:**
|
11
|
+
|
12
|
+
- Fix parsing of "simple" multi-line VALUE [\#24](https://github.com/smortex/yaml-sort/pull/24) ([smortex](https://github.com/smortex))
|
13
|
+
|
14
|
+
## [v2.2.1](https://github.com/smortex/yaml-sort/tree/v2.2.1) (2023-01-04)
|
15
|
+
|
16
|
+
[Full Changelog](https://github.com/smortex/yaml-sort/compare/v2.2.0...v2.2.1)
|
17
|
+
|
18
|
+
**Fixed bugs:**
|
19
|
+
|
20
|
+
- Fix parsing of dictionaries with quotes in KEY/VALUE [\#21](https://github.com/smortex/yaml-sort/pull/21) ([smortex](https://github.com/smortex))
|
21
|
+
|
6
22
|
## [v2.2.0](https://github.com/smortex/yaml-sort/tree/v2.2.0) (2022-09-27)
|
7
23
|
|
8
24
|
[Full Changelog](https://github.com/smortex/yaml-sort/compare/v2.1.1...v2.2.0)
|
data/lib/yaml/sort/parser.rb
CHANGED
@@ -13,7 +13,7 @@ module Yaml
|
|
13
13
|
module Sort
|
14
14
|
class Parser < Racc::Parser
|
15
15
|
|
16
|
-
module_eval(<<'...end parser.ra/module_eval...', 'parser.ra',
|
16
|
+
module_eval(<<'...end parser.ra/module_eval...', 'parser.ra', 36)
|
17
17
|
|
18
18
|
def scan(text)
|
19
19
|
text = "---\n#{text}" unless text.start_with?("---\n")
|
@@ -27,11 +27,16 @@ def scan(text)
|
|
27
27
|
@fakelineno = 0
|
28
28
|
@position = 0
|
29
29
|
@indent_stack = []
|
30
|
+
@anchors = {}
|
30
31
|
|
31
32
|
until s.eos?
|
32
33
|
if scan_value
|
33
34
|
@position += s.matched_size if s.scan(/[[:blank:]]*/)
|
34
35
|
case
|
36
|
+
when s.scan(/&[[:alnum:]]+/)
|
37
|
+
emit(:ANCHOR, s.matched[1..-1])
|
38
|
+
when s.scan(/\*[[:alnum:]]+/)
|
39
|
+
emit(:ALIAS, s.matched[1..-1])
|
35
40
|
when s.scan(/[|>][-+]?(?=\n)/)
|
36
41
|
match = s.matched
|
37
42
|
|
@@ -58,10 +63,11 @@ def scan(text)
|
|
58
63
|
match += s.scan(/'/)
|
59
64
|
end
|
60
65
|
emit(:VALUE, match)
|
61
|
-
when s.
|
62
|
-
match = s.
|
63
|
-
|
64
|
-
|
66
|
+
when s.match?(/\S+/)
|
67
|
+
match = s.scan_until(/$/)
|
68
|
+
|
69
|
+
while s.match?("\n" + last_indent_value + " ")
|
70
|
+
match += s.scan(/\n[^\n]+(?=\n)/)
|
65
71
|
end
|
66
72
|
emit(:VALUE, match)
|
67
73
|
end
|
@@ -77,10 +83,11 @@ def scan(text)
|
|
77
83
|
when s.scan(/\n[[:blank:]]*#.*/) then emit(:COMMENT, s.matched)
|
78
84
|
when s.scan(/\n([[:blank:]]*-) */) then emit(:ITEM, s.matched, indent: s.captures[0])
|
79
85
|
when s.scan(/\n[[:blank:]]*\.\.\./) then emit(:END_OF_DOCUMENT, s.matched)
|
80
|
-
when s.scan(/\n?([[:blank:]]*)(
|
86
|
+
when s.scan(/\n?([[:blank:]]*)(.+?:)(?=[ \n])/)
|
81
87
|
indent = s.captures[0]
|
82
88
|
indent = last_indent_value + indent + " " unless s.matched.start_with?("\n")
|
83
89
|
emit(:KEY, s.matched, indent: indent, value: s.captures[1])
|
90
|
+
scan_value = true if s.rest
|
84
91
|
|
85
92
|
when s.scan(/\n\z/)
|
86
93
|
# Done
|
@@ -141,8 +148,19 @@ def emit(token, match, length: nil, indent: nil, value: nil)
|
|
141
148
|
@indent_stack.push(indent) unless @indent_stack.last == indent
|
142
149
|
end
|
143
150
|
|
151
|
+
value ||= match
|
152
|
+
|
153
|
+
if token == :KEY && value == '<<:'
|
154
|
+
message = <<~MESSAGE
|
155
|
+
#{@filename}:#{@lineno}: '<<:' references are not sortable:
|
156
|
+
#{@lines[@lineno - 1].chomp}
|
157
|
+
#{indent}#{" " * @position}^#{"~" * (length - indent.length - 1)}
|
158
|
+
MESSAGE
|
159
|
+
raise(Racc::ParseError, message)
|
160
|
+
end
|
161
|
+
|
144
162
|
exvalue = {
|
145
|
-
value: value
|
163
|
+
value: value,
|
146
164
|
lineno: @lineno,
|
147
165
|
position: @position,
|
148
166
|
length: length,
|
@@ -193,50 +211,61 @@ end
|
|
193
211
|
##### State transition tables begin ###
|
194
212
|
|
195
213
|
racc_action_table = [
|
196
|
-
5,
|
197
|
-
|
214
|
+
5, 10, 2, 12, 3, 8, 5, 10, 13, 12,
|
215
|
+
19, 8, 5, 10, 14, 12, 21, 8, 5, 10,
|
216
|
+
nil, 12, nil, 8, 5, 10, nil, 12, nil, 8,
|
217
|
+
10, 15, 17, 12 ]
|
198
218
|
|
199
219
|
racc_action_check = [
|
200
|
-
2, 2, 0, 2,
|
201
|
-
|
220
|
+
2, 2, 0, 2, 1, 2, 10, 10, 3, 10,
|
221
|
+
10, 10, 12, 12, 4, 12, 12, 12, 19, 19,
|
222
|
+
nil, 19, nil, 19, 21, 21, nil, 21, nil, 21,
|
223
|
+
6, 6, 7, 7 ]
|
202
224
|
|
203
225
|
racc_action_pointer = [
|
204
|
-
0,
|
205
|
-
nil,
|
226
|
+
0, 4, -4, 8, 11, nil, 25, 26, nil, nil,
|
227
|
+
2, nil, 8, nil, nil, nil, nil, nil, nil, 14,
|
228
|
+
nil, 20, nil, nil, nil ]
|
206
229
|
|
207
230
|
racc_action_default = [
|
208
|
-
-
|
209
|
-
-
|
231
|
+
-15, -15, -15, -15, -2, -3, -15, -15, -6, -8,
|
232
|
+
-15, -12, -15, 25, -1, -4, -7, -5, -11, -15,
|
233
|
+
-10, -15, -14, -9, -13 ]
|
210
234
|
|
211
235
|
racc_goto_table = [
|
212
|
-
4, 1,
|
236
|
+
4, 1, 16, 18, nil, nil, nil, nil, 20, nil,
|
237
|
+
22, nil, nil, nil, nil, nil, nil, 23, nil, 24 ]
|
213
238
|
|
214
239
|
racc_goto_check = [
|
215
|
-
2, 1, 5, 6, nil, nil, nil, 2, nil,
|
240
|
+
2, 1, 5, 6, nil, nil, nil, nil, 2, nil,
|
241
|
+
2, nil, nil, nil, nil, nil, nil, 2, nil, 2 ]
|
216
242
|
|
217
243
|
racc_goto_pointer = [
|
218
244
|
nil, 1, -2, nil, nil, -4, -4 ]
|
219
245
|
|
220
246
|
racc_goto_default = [
|
221
|
-
nil, nil, nil, 6, 7,
|
247
|
+
nil, nil, nil, 6, 7, 9, 11 ]
|
222
248
|
|
223
249
|
racc_reduce_table = [
|
224
250
|
0, 0, :racc_error,
|
225
|
-
3,
|
226
|
-
2,
|
227
|
-
1,
|
228
|
-
2,
|
229
|
-
2,
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
2, 14, :_reduce_11
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
251
|
+
3, 11, :_reduce_1,
|
252
|
+
2, 11, :_reduce_2,
|
253
|
+
1, 12, :_reduce_3,
|
254
|
+
2, 12, :_reduce_4,
|
255
|
+
2, 12, :_reduce_5,
|
256
|
+
1, 12, :_reduce_6,
|
257
|
+
2, 13, :_reduce_7,
|
258
|
+
1, 13, :_reduce_8,
|
259
|
+
3, 15, :_reduce_9,
|
260
|
+
2, 15, :_reduce_10,
|
261
|
+
2, 14, :_reduce_11,
|
262
|
+
1, 14, :_reduce_12,
|
263
|
+
3, 16, :_reduce_13,
|
264
|
+
2, 16, :_reduce_14 ]
|
265
|
+
|
266
|
+
racc_reduce_n = 15
|
267
|
+
|
268
|
+
racc_shift_n = 25
|
240
269
|
|
241
270
|
racc_token_table = {
|
242
271
|
false => 0,
|
@@ -246,9 +275,11 @@ racc_token_table = {
|
|
246
275
|
:VALUE => 4,
|
247
276
|
:KEY => 5,
|
248
277
|
:UNINDENT => 6,
|
249
|
-
:ITEM => 7
|
278
|
+
:ITEM => 7,
|
279
|
+
:ANCHOR => 8,
|
280
|
+
:ALIAS => 9 }
|
250
281
|
|
251
|
-
racc_nt_base =
|
282
|
+
racc_nt_base = 10
|
252
283
|
|
253
284
|
racc_use_result_var = true
|
254
285
|
|
@@ -277,6 +308,8 @@ Racc_token_to_s_table = [
|
|
277
308
|
"KEY",
|
278
309
|
"UNINDENT",
|
279
310
|
"ITEM",
|
311
|
+
"ANCHOR",
|
312
|
+
"ALIAS",
|
280
313
|
"$start",
|
281
314
|
"document",
|
282
315
|
"value",
|
@@ -326,43 +359,64 @@ module_eval(<<'.,.,', 'parser.ra', 14)
|
|
326
359
|
end
|
327
360
|
.,.,
|
328
361
|
|
329
|
-
module_eval(<<'.,.,', 'parser.ra',
|
362
|
+
module_eval(<<'.,.,', 'parser.ra', 15)
|
330
363
|
def _reduce_6(val, _values, result)
|
331
|
-
|
364
|
+
result = Alias.new(@anchors, val[0])
|
332
365
|
result
|
333
366
|
end
|
334
367
|
.,.,
|
335
368
|
|
336
369
|
module_eval(<<'.,.,', 'parser.ra', 17)
|
337
370
|
def _reduce_7(val, _values, result)
|
338
|
-
result =
|
371
|
+
val[0].add_item(*val[1]); result = val[0]
|
339
372
|
result
|
340
373
|
end
|
341
374
|
.,.,
|
342
375
|
|
343
|
-
module_eval(<<'.,.,', 'parser.ra',
|
376
|
+
module_eval(<<'.,.,', 'parser.ra', 18)
|
344
377
|
def _reduce_8(val, _values, result)
|
345
|
-
result =
|
378
|
+
result = Dictionary.create(*val[0])
|
346
379
|
result
|
347
380
|
end
|
348
381
|
.,.,
|
349
382
|
|
350
|
-
module_eval(<<'.,.,', 'parser.ra',
|
383
|
+
module_eval(<<'.,.,', 'parser.ra', 20)
|
351
384
|
def _reduce_9(val, _values, result)
|
352
|
-
val[
|
385
|
+
@anchors[val[1][:value]] = val[2]; result = [Scalar.new(val[0]), Alias.new(@anchors, val[1])]
|
353
386
|
result
|
354
387
|
end
|
355
388
|
.,.,
|
356
389
|
|
357
|
-
module_eval(<<'.,.,', 'parser.ra',
|
390
|
+
module_eval(<<'.,.,', 'parser.ra', 21)
|
358
391
|
def _reduce_10(val, _values, result)
|
359
|
-
result =
|
392
|
+
result = [Scalar.new(val[0]), val[1]]
|
360
393
|
result
|
361
394
|
end
|
362
395
|
.,.,
|
363
396
|
|
364
|
-
module_eval(<<'.,.,', 'parser.ra',
|
397
|
+
module_eval(<<'.,.,', 'parser.ra', 23)
|
365
398
|
def _reduce_11(val, _values, result)
|
399
|
+
val[0].add_item(*val[1]); result = val[0]
|
400
|
+
result
|
401
|
+
end
|
402
|
+
.,.,
|
403
|
+
|
404
|
+
module_eval(<<'.,.,', 'parser.ra', 24)
|
405
|
+
def _reduce_12(val, _values, result)
|
406
|
+
result = List.create(*val[0])
|
407
|
+
result
|
408
|
+
end
|
409
|
+
.,.,
|
410
|
+
|
411
|
+
module_eval(<<'.,.,', 'parser.ra', 26)
|
412
|
+
def _reduce_13(val, _values, result)
|
413
|
+
@anchors[val[1][:value]] = val[2]; result = [Item.new(val[0]), Alias.new(@anchors, val[1])]
|
414
|
+
result
|
415
|
+
end
|
416
|
+
.,.,
|
417
|
+
|
418
|
+
module_eval(<<'.,.,', 'parser.ra', 27)
|
419
|
+
def _reduce_14(val, _values, result)
|
366
420
|
result = [Item.new(val[0]), val[1]]
|
367
421
|
result
|
368
422
|
end
|
data/lib/yaml/sort/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: yaml-sort
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.2.
|
4
|
+
version: 2.2.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Romain Tartière
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2023-01-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: cri
|
@@ -121,7 +121,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
121
121
|
- !ruby/object:Gem::Version
|
122
122
|
version: '0'
|
123
123
|
requirements: []
|
124
|
-
rubygems_version: 3.3.
|
124
|
+
rubygems_version: 3.3.26
|
125
125
|
signing_key:
|
126
126
|
specification_version: 4
|
127
127
|
summary: Sort lines in YAML files in a predictable order
|