yaml-sort 2.2.0 → 2.2.1

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
2
  SHA256:
3
- metadata.gz: 6c27eb85cd2257c1d9ae801f0de2bcf360f4980e40479599745ecea41f4aa1f0
4
- data.tar.gz: 05a1eb6551c2c671ca4e1ff01ce6acd91f3954fd7eeb8b70238bb48df45c1365
3
+ metadata.gz: 71ee5e9950197312df22f8cb27e87dd7fe223f8c320969edcb7130c2c9548ed5
4
+ data.tar.gz: ca1948fa942e772f7ed9caade6b91683c92f7c20b685f24e508d4f669826ebef
5
5
  SHA512:
6
- metadata.gz: 28b1e39e69330c1d4f4f68884fb84a8ba8dcc5411315a4b37e51391a4f32b1495fbb2f90eeaa78fea283e1c1ed06f0d030f35c9642de578e4e2665d76546a8ed
7
- data.tar.gz: '0218e2f44f0a27dc1d5ca720493be401f2e9e55276b4de733ca37f716e9b92cc1c963a0c716c34f219fe3efc6704e21df570564f356394253bc790ecc7c9644f'
6
+ metadata.gz: 37f4ae4497b011da8e928f5d7c9ba315105e80a5de50f4052320fb7409de469a45a51c92d143bac5061706e7e5e3bcfb422a461ffcfa0ab4b2f1d2df7309c39c
7
+ data.tar.gz: 4ba38b243d77ea33aa89c933eea5a3b98e2d7bed158d664d8f1020636c609e99d48c10cf462ec5e7db822ff73f3abf4f20693fc4ac0ea7585ae3ee343a316644
data/CHANGELOG.md CHANGED
@@ -3,6 +3,14 @@ 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.1](https://github.com/smortex/yaml-sort/tree/v2.2.1) (2023-01-04)
7
+
8
+ [Full Changelog](https://github.com/smortex/yaml-sort/compare/v2.2.0...v2.2.1)
9
+
10
+ **Fixed bugs:**
11
+
12
+ - Fix parsing of dictionaries with quotes in KEY/VALUE [\#21](https://github.com/smortex/yaml-sort/pull/21) ([smortex](https://github.com/smortex))
13
+
6
14
  ## [v2.2.0](https://github.com/smortex/yaml-sort/tree/v2.2.0) (2022-09-27)
7
15
 
8
16
  [Full Changelog](https://github.com/smortex/yaml-sort/compare/v2.1.1...v2.2.0)
@@ -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', 33)
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
 
@@ -77,10 +82,11 @@ def scan(text)
77
82
  when s.scan(/\n[[:blank:]]*#.*/) then emit(:COMMENT, s.matched)
78
83
  when s.scan(/\n([[:blank:]]*-) */) then emit(:ITEM, s.matched, indent: s.captures[0])
79
84
  when s.scan(/\n[[:blank:]]*\.\.\./) then emit(:END_OF_DOCUMENT, s.matched)
80
- when s.scan(/\n?([[:blank:]]*)(.+:)(?=[ \n])/)
85
+ when s.scan(/\n?([[:blank:]]*)(.+?:)(?=[ \n])/)
81
86
  indent = s.captures[0]
82
87
  indent = last_indent_value + indent + " " unless s.matched.start_with?("\n")
83
88
  emit(:KEY, s.matched, indent: indent, value: s.captures[1])
89
+ scan_value = true if s.rest
84
90
 
85
91
  when s.scan(/\n\z/)
86
92
  # Done
@@ -141,8 +147,19 @@ def emit(token, match, length: nil, indent: nil, value: nil)
141
147
  @indent_stack.push(indent) unless @indent_stack.last == indent
142
148
  end
143
149
 
150
+ value ||= match
151
+
152
+ if token == :KEY && value == '<<:'
153
+ message = <<~MESSAGE
154
+ #{@filename}:#{@lineno}: '<<:' references are not sortable:
155
+ #{@lines[@lineno - 1].chomp}
156
+ #{indent}#{" " * @position}^#{"~" * (length - indent.length - 1)}
157
+ MESSAGE
158
+ raise(Racc::ParseError, message)
159
+ end
160
+
144
161
  exvalue = {
145
- value: value || match,
162
+ value: value,
146
163
  lineno: @lineno,
147
164
  position: @position,
148
165
  length: length,
@@ -193,50 +210,61 @@ end
193
210
  ##### State transition tables begin ###
194
211
 
195
212
  racc_action_table = [
196
- 5, 9, 2, 11, 5, 9, 3, 11, 5, 9,
197
- 12, 11, 9, 14, 16, 11, 13 ]
213
+ 5, 10, 2, 12, 3, 8, 5, 10, 13, 12,
214
+ 19, 8, 5, 10, 14, 12, 21, 8, 5, 10,
215
+ nil, 12, nil, 8, 5, 10, nil, 12, nil, 8,
216
+ 10, 15, 17, 12 ]
198
217
 
199
218
  racc_action_check = [
200
- 2, 2, 0, 2, 9, 9, 1, 9, 11, 11,
201
- 3, 11, 6, 6, 7, 7, 4 ]
219
+ 2, 2, 0, 2, 1, 2, 10, 10, 3, 10,
220
+ 10, 10, 12, 12, 4, 12, 12, 12, 19, 19,
221
+ nil, 19, nil, 19, 21, 21, nil, 21, nil, 21,
222
+ 6, 6, 7, 7 ]
202
223
 
203
224
  racc_action_pointer = [
204
- 0, 6, -4, 10, 13, nil, 7, 8, nil, 0,
205
- nil, 4, nil, nil, nil, nil, nil, nil, nil, nil ]
225
+ 0, 4, -4, 8, 11, nil, 25, 26, nil, nil,
226
+ 2, nil, 8, nil, nil, nil, nil, nil, nil, 14,
227
+ nil, 20, nil, nil, nil ]
206
228
 
207
229
  racc_action_default = [
208
- -12, -12, -12, -12, -2, -3, -12, -12, -7, -12,
209
- -10, -12, 20, -1, -4, -6, -5, -9, -8, -11 ]
230
+ -15, -15, -15, -15, -2, -3, -15, -15, -6, -8,
231
+ -15, -12, -15, 25, -1, -4, -7, -5, -11, -15,
232
+ -10, -15, -14, -9, -13 ]
210
233
 
211
234
  racc_goto_table = [
212
- 4, 1, 15, 17, nil, nil, nil, 18, nil, 19 ]
235
+ 4, 1, 16, 18, nil, nil, nil, nil, 20, nil,
236
+ 22, nil, nil, nil, nil, nil, nil, 23, nil, 24 ]
213
237
 
214
238
  racc_goto_check = [
215
- 2, 1, 5, 6, nil, nil, nil, 2, nil, 2 ]
239
+ 2, 1, 5, 6, nil, nil, nil, nil, 2, nil,
240
+ 2, nil, nil, nil, nil, nil, nil, 2, nil, 2 ]
216
241
 
217
242
  racc_goto_pointer = [
218
243
  nil, 1, -2, nil, nil, -4, -4 ]
219
244
 
220
245
  racc_goto_default = [
221
- nil, nil, nil, 6, 7, 8, 10 ]
246
+ nil, nil, nil, 6, 7, 9, 11 ]
222
247
 
223
248
  racc_reduce_table = [
224
249
  0, 0, :racc_error,
225
- 3, 9, :_reduce_1,
226
- 2, 9, :_reduce_2,
227
- 1, 10, :_reduce_3,
228
- 2, 10, :_reduce_4,
229
- 2, 10, :_reduce_5,
230
- 2, 11, :_reduce_6,
231
- 1, 11, :_reduce_7,
232
- 2, 13, :_reduce_8,
233
- 2, 12, :_reduce_9,
234
- 1, 12, :_reduce_10,
235
- 2, 14, :_reduce_11 ]
236
-
237
- racc_reduce_n = 12
238
-
239
- racc_shift_n = 20
250
+ 3, 11, :_reduce_1,
251
+ 2, 11, :_reduce_2,
252
+ 1, 12, :_reduce_3,
253
+ 2, 12, :_reduce_4,
254
+ 2, 12, :_reduce_5,
255
+ 1, 12, :_reduce_6,
256
+ 2, 13, :_reduce_7,
257
+ 1, 13, :_reduce_8,
258
+ 3, 15, :_reduce_9,
259
+ 2, 15, :_reduce_10,
260
+ 2, 14, :_reduce_11,
261
+ 1, 14, :_reduce_12,
262
+ 3, 16, :_reduce_13,
263
+ 2, 16, :_reduce_14 ]
264
+
265
+ racc_reduce_n = 15
266
+
267
+ racc_shift_n = 25
240
268
 
241
269
  racc_token_table = {
242
270
  false => 0,
@@ -246,9 +274,11 @@ racc_token_table = {
246
274
  :VALUE => 4,
247
275
  :KEY => 5,
248
276
  :UNINDENT => 6,
249
- :ITEM => 7 }
277
+ :ITEM => 7,
278
+ :ANCHOR => 8,
279
+ :ALIAS => 9 }
250
280
 
251
- racc_nt_base = 8
281
+ racc_nt_base = 10
252
282
 
253
283
  racc_use_result_var = true
254
284
 
@@ -277,6 +307,8 @@ Racc_token_to_s_table = [
277
307
  "KEY",
278
308
  "UNINDENT",
279
309
  "ITEM",
310
+ "ANCHOR",
311
+ "ALIAS",
280
312
  "$start",
281
313
  "document",
282
314
  "value",
@@ -326,43 +358,64 @@ module_eval(<<'.,.,', 'parser.ra', 14)
326
358
  end
327
359
  .,.,
328
360
 
329
- module_eval(<<'.,.,', 'parser.ra', 16)
361
+ module_eval(<<'.,.,', 'parser.ra', 15)
330
362
  def _reduce_6(val, _values, result)
331
- val[0].add_item(*val[1]); result = val[0]
363
+ result = Alias.new(@anchors, val[0])
332
364
  result
333
365
  end
334
366
  .,.,
335
367
 
336
368
  module_eval(<<'.,.,', 'parser.ra', 17)
337
369
  def _reduce_7(val, _values, result)
338
- result = Dictionary.create(*val[0])
370
+ val[0].add_item(*val[1]); result = val[0]
339
371
  result
340
372
  end
341
373
  .,.,
342
374
 
343
- module_eval(<<'.,.,', 'parser.ra', 19)
375
+ module_eval(<<'.,.,', 'parser.ra', 18)
344
376
  def _reduce_8(val, _values, result)
345
- result = [Scalar.new(val[0]), val[1]]
377
+ result = Dictionary.create(*val[0])
346
378
  result
347
379
  end
348
380
  .,.,
349
381
 
350
- module_eval(<<'.,.,', 'parser.ra', 21)
382
+ module_eval(<<'.,.,', 'parser.ra', 20)
351
383
  def _reduce_9(val, _values, result)
352
- val[0].add_item(*val[1]); result = val[0]
384
+ @anchors[val[1][:value]] = val[2]; result = [Scalar.new(val[0]), Alias.new(@anchors, val[1])]
353
385
  result
354
386
  end
355
387
  .,.,
356
388
 
357
- module_eval(<<'.,.,', 'parser.ra', 22)
389
+ module_eval(<<'.,.,', 'parser.ra', 21)
358
390
  def _reduce_10(val, _values, result)
359
- result = List.create(*val[0])
391
+ result = [Scalar.new(val[0]), val[1]]
360
392
  result
361
393
  end
362
394
  .,.,
363
395
 
364
- module_eval(<<'.,.,', 'parser.ra', 24)
396
+ module_eval(<<'.,.,', 'parser.ra', 23)
365
397
  def _reduce_11(val, _values, result)
398
+ val[0].add_item(*val[1]); result = val[0]
399
+ result
400
+ end
401
+ .,.,
402
+
403
+ module_eval(<<'.,.,', 'parser.ra', 24)
404
+ def _reduce_12(val, _values, result)
405
+ result = List.create(*val[0])
406
+ result
407
+ end
408
+ .,.,
409
+
410
+ module_eval(<<'.,.,', 'parser.ra', 26)
411
+ def _reduce_13(val, _values, result)
412
+ @anchors[val[1][:value]] = val[2]; result = [Item.new(val[0]), Alias.new(@anchors, val[1])]
413
+ result
414
+ end
415
+ .,.,
416
+
417
+ module_eval(<<'.,.,', 'parser.ra', 27)
418
+ def _reduce_14(val, _values, result)
366
419
  result = [Item.new(val[0]), val[1]]
367
420
  result
368
421
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Yaml
4
4
  module Sort
5
- VERSION = "2.2.0"
5
+ VERSION = "2.2.1"
6
6
  end
7
7
  end
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.0
4
+ version: 2.2.1
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: 2022-09-27 00:00:00.000000000 Z
11
+ date: 2023-01-04 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.22
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