yaml-sort 2.0.1 → 2.1.1
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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +27 -2
- data/Rakefile +1 -1
- data/lib/yaml/sort/cli.rb +20 -4
- data/lib/yaml/sort/parser.rb +50 -51
- data/lib/yaml/sort/tasks/puppet.rb +2 -2
- data/lib/yaml/sort/tasks/rails.rb +2 -2
- data/lib/yaml/sort/version.rb +1 -1
- metadata +7 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 813b1d18ae4a2cb6b57ebde8dc720c06ff9125417ab245d6cc15e22467e8f5ef
|
4
|
+
data.tar.gz: 5d334e4fd7ab15319c225e549a1e7e38319f62a3ecec62a855b40c8e00cba036
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 84b534524792c4218449a7724e1673d09058afb2b2c838001e2092e144d8caaeadf51ea5cf415d52a6f5b1ca284ac3977785871344e317d0c61a0414b715d2d8
|
7
|
+
data.tar.gz: 211409b7ade1b5cace67a86ea71a3fe952398a03165a099a201760ad47e3a01a2da99e7ecd359bc80f63d988396b63afc7a42141899f7ef316ac1dd0aa2c1e5a
|
data/CHANGELOG.md
CHANGED
@@ -3,9 +3,34 @@ 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
|
-
## [
|
6
|
+
## [v2.1.1](https://github.com/smortex/yaml-sort/tree/v2.1.1) (2022-07-03)
|
7
7
|
|
8
|
-
[Full Changelog](https://github.com/smortex/yaml-sort/compare/v2.
|
8
|
+
[Full Changelog](https://github.com/smortex/yaml-sort/compare/v2.1.0...v2.1.1)
|
9
|
+
|
10
|
+
**Fixed bugs:**
|
11
|
+
|
12
|
+
- Fix passing-around Aruba FakeKernel [\#13](https://github.com/smortex/yaml-sort/pull/13) ([smortex](https://github.com/smortex))
|
13
|
+
|
14
|
+
## [v2.1.0](https://github.com/smortex/yaml-sort/tree/v2.1.0) (2022-07-03)
|
15
|
+
|
16
|
+
[Full Changelog](https://github.com/smortex/yaml-sort/compare/v2.0.2...v2.1.0)
|
17
|
+
|
18
|
+
**Implemented enhancements:**
|
19
|
+
|
20
|
+
- Make the Rake tasks silent [\#11](https://github.com/smortex/yaml-sort/pull/11) ([smortex](https://github.com/smortex))
|
21
|
+
- Improve --lint by showing a diff on error [\#10](https://github.com/smortex/yaml-sort/pull/10) ([smortex](https://github.com/smortex))
|
22
|
+
|
23
|
+
## [v2.0.2](https://github.com/smortex/yaml-sort/tree/v2.0.2) (2022-06-10)
|
24
|
+
|
25
|
+
[Full Changelog](https://github.com/smortex/yaml-sort/compare/v2.0.1...v2.0.2)
|
26
|
+
|
27
|
+
**Fixed bugs:**
|
28
|
+
|
29
|
+
- Fix infinite loops when processing files with trailing whitespace [\#9](https://github.com/smortex/yaml-sort/pull/9) ([smortex](https://github.com/smortex))
|
30
|
+
|
31
|
+
## [v2.0.1](https://github.com/smortex/yaml-sort/tree/v2.0.1) (2022-06-01)
|
32
|
+
|
33
|
+
[Full Changelog](https://github.com/smortex/yaml-sort/compare/v2.0.0...v2.0.1)
|
9
34
|
|
10
35
|
**Fixed bugs:**
|
11
36
|
|
data/Rakefile
CHANGED
@@ -24,7 +24,7 @@ task cucumber: ["lib/yaml/sort/parser.rb"]
|
|
24
24
|
|
25
25
|
require "github_changelog_generator/task"
|
26
26
|
GitHubChangelogGenerator::RakeTask.new :changelog do |config|
|
27
|
-
config.future_release = Yaml::Sort::VERSION
|
27
|
+
config.future_release = "v#{Yaml::Sort::VERSION}"
|
28
28
|
config.header = <<~HEADER.chomp
|
29
29
|
# Changelog
|
30
30
|
All notable changes to this project will be documented in this file.
|
data/lib/yaml/sort/cli.rb
CHANGED
@@ -3,6 +3,7 @@
|
|
3
3
|
require "optparse"
|
4
4
|
|
5
5
|
require "cri"
|
6
|
+
require "tempfile"
|
6
7
|
|
7
8
|
module Yaml
|
8
9
|
module Sort
|
@@ -11,7 +12,7 @@ module Yaml
|
|
11
12
|
@parser = Yaml::Sort::Parser.new
|
12
13
|
end
|
13
14
|
|
14
|
-
def execute(argv) # rubocop:disable Metrics/AbcSize, Metrics/MethodLength, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
|
15
|
+
def execute(argv, kernel = Kernel) # rubocop:disable Metrics/AbcSize, Metrics/MethodLength, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
|
15
16
|
options = {
|
16
17
|
in_place: false,
|
17
18
|
lint: false,
|
@@ -25,7 +26,7 @@ module Yaml
|
|
25
26
|
opts.on("-l", "--lint", "Ensure files content is sorted as expected") do
|
26
27
|
options[:lint] = true
|
27
28
|
end
|
28
|
-
end.parse!
|
29
|
+
end.parse!(argv)
|
29
30
|
|
30
31
|
if !options[:in_place] && !options[:lint] && argv.count > 1
|
31
32
|
warn "Sorting multiple YAML document to stdout does not make sense"
|
@@ -47,7 +48,7 @@ module Yaml
|
|
47
48
|
end
|
48
49
|
end
|
49
50
|
|
50
|
-
@exit_code
|
51
|
+
kernel.exit(@exit_code)
|
51
52
|
end
|
52
53
|
|
53
54
|
def process_document(filename, options)
|
@@ -78,13 +79,28 @@ module Yaml
|
|
78
79
|
File.write(filename, sorted_yaml)
|
79
80
|
elsif options[:lint]
|
80
81
|
if yaml != sorted_yaml
|
81
|
-
|
82
|
+
show_diff(filename, yaml, sorted_yaml)
|
82
83
|
@exit_code = 1
|
83
84
|
end
|
84
85
|
else
|
85
86
|
puts sorted_yaml
|
86
87
|
end
|
87
88
|
end
|
89
|
+
|
90
|
+
def show_diff(filename, actual, expected)
|
91
|
+
filename ||= "<stdin>"
|
92
|
+
|
93
|
+
a = Tempfile.new
|
94
|
+
a.write(actual)
|
95
|
+
a.close
|
96
|
+
|
97
|
+
b = Tempfile.new
|
98
|
+
b.write(expected)
|
99
|
+
b.close
|
100
|
+
|
101
|
+
warn "diff #{File.join("a", filename)} #{File.join("b", filename)}"
|
102
|
+
warn `diff -u --label "#{File.join("a", filename)}" #{a.path} --label "#{File.join("b", filename)}" #{b.path}`
|
103
|
+
end
|
88
104
|
end
|
89
105
|
end
|
90
106
|
end
|
data/lib/yaml/sort/parser.rb
CHANGED
@@ -30,43 +30,42 @@ def scan(text)
|
|
30
30
|
|
31
31
|
until s.eos?
|
32
32
|
if scan_value
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
break
|
51
|
-
end
|
52
|
-
end
|
53
|
-
emit(:VALUE, match)
|
54
|
-
when s.scan(/'/)
|
55
|
-
match = s.matched
|
56
|
-
loop do
|
57
|
-
match += s.scan_until(/'/)
|
58
|
-
break unless s.match?(/'/)
|
59
|
-
match += s.scan(/'/)
|
60
|
-
end
|
61
|
-
emit(:VALUE, match)
|
62
|
-
when s.scan(/\S+/)
|
63
|
-
match = s.matched
|
64
|
-
until s.match?(/[\n]/) || s.eos?
|
65
|
-
match += s.scan(/[^\n]+/)
|
33
|
+
@position += s.matched_size if s.scan(/[[:blank:]]*/)
|
34
|
+
case
|
35
|
+
when s.scan(/[|>][-+]?(?=\n)/)
|
36
|
+
match = s.matched
|
37
|
+
|
38
|
+
while s.match?("\n" + last_indent_value + " ")
|
39
|
+
match += s.scan(/\n[^\n]+(?=\n)/)
|
40
|
+
end
|
41
|
+
emit(:VALUE, match)
|
42
|
+
when s.scan(/"/)
|
43
|
+
match = s.matched
|
44
|
+
loop do
|
45
|
+
match += s.scan_until(/"|\\/)
|
46
|
+
if match[-1] == "\\"
|
47
|
+
match += s.scan(/.|\n/)
|
48
|
+
else
|
49
|
+
break
|
66
50
|
end
|
67
|
-
emit(:VALUE, match)
|
68
51
|
end
|
52
|
+
emit(:VALUE, match)
|
53
|
+
when s.scan(/'/)
|
54
|
+
match = s.matched
|
55
|
+
loop do
|
56
|
+
match += s.scan_until(/'/)
|
57
|
+
break unless s.match?(/'/)
|
58
|
+
match += s.scan(/'/)
|
59
|
+
end
|
60
|
+
emit(:VALUE, match)
|
61
|
+
when s.scan(/\S+/)
|
62
|
+
match = s.matched
|
63
|
+
until s.match?(/[\n]/) || s.eos?
|
64
|
+
match += s.scan(/[^\n]+/)
|
65
|
+
end
|
66
|
+
emit(:VALUE, match)
|
69
67
|
end
|
68
|
+
s.scan(/[[:blank:]]*/)
|
70
69
|
scan_value = false
|
71
70
|
else
|
72
71
|
case
|
@@ -88,23 +87,23 @@ def scan(text)
|
|
88
87
|
when s.match?(/./)
|
89
88
|
scan_value = true
|
90
89
|
else
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
90
|
+
message = if @lines[@lineno - 1][@position] == "\n"
|
91
|
+
<<~MESSAGE
|
92
|
+
#{@filename}:#{@lineno + 1}: unexpected content
|
93
|
+
#{@lines[@lineno].chomp}
|
94
|
+
^#{"~" * (@lines[@lineno].chomp.length - 1)}
|
95
|
+
MESSAGE
|
96
|
+
else
|
97
|
+
<<~MESSAGE
|
98
|
+
#{@filename}:#{@lineno}: unexpected content
|
99
|
+
#{@lines[@lineno - 1].chomp}
|
100
|
+
#{" " * @position}^
|
101
|
+
MESSAGE
|
102
|
+
end
|
103
|
+
raise(Racc::ParseError, message)
|
104
|
+
end
|
105
|
+
end
|
106
|
+
end
|
108
107
|
|
109
108
|
unindent
|
110
109
|
|
@@ -3,11 +3,11 @@
|
|
3
3
|
namespace :lint do
|
4
4
|
desc "Check Hiera data content ordering"
|
5
5
|
task :hiera_data_ordering do
|
6
|
-
sh "yaml-sort", "--lint", *Dir.glob("data/**/*.yaml")
|
6
|
+
sh "yaml-sort", "--lint", *Dir.glob("data/**/*.yaml"), verbose: false
|
7
7
|
end
|
8
8
|
end
|
9
9
|
|
10
10
|
desc "Reorder Hiera data in-place"
|
11
11
|
task :reorder_hiera_data do
|
12
|
-
sh "yaml-sort", "--in-place", *Dir.glob("data/**/*.yaml")
|
12
|
+
sh "yaml-sort", "--in-place", *Dir.glob("data/**/*.yaml"), verbose: false
|
13
13
|
end
|
@@ -3,11 +3,11 @@
|
|
3
3
|
namespace :test do
|
4
4
|
desc "Check translations content ordering"
|
5
5
|
task :translations_ordering do
|
6
|
-
sh "yaml-sort", "--lint", *Dir.glob("config/locales/**/*.yml")
|
6
|
+
sh "yaml-sort", "--lint", *Dir.glob("config/locales/**/*.yml"), verbose: false
|
7
7
|
end
|
8
8
|
end
|
9
9
|
|
10
10
|
desc "Reorder translations in-place"
|
11
11
|
task :reorder_translations do
|
12
|
-
sh "yaml-sort", "--in-place", *Dir.glob("config/locales/**/*.yml")
|
12
|
+
sh "yaml-sort", "--in-place", *Dir.glob("config/locales/**/*.yml"), verbose: false
|
13
13
|
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.
|
4
|
+
version: 2.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Romain Tartière
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-07-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: cri
|
@@ -66,7 +66,7 @@ dependencies:
|
|
66
66
|
- - ">="
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '0'
|
69
|
-
description:
|
69
|
+
description:
|
70
70
|
email:
|
71
71
|
- romain@blogreen.org
|
72
72
|
executables:
|
@@ -104,7 +104,7 @@ metadata:
|
|
104
104
|
source_code_uri: https://github.com/smortex/yaml-sort
|
105
105
|
changelog_uri: https://github.com/smortex/yaml-sort/blob/master/CHANGELOG.md
|
106
106
|
rubygems_mfa_required: 'true'
|
107
|
-
post_install_message:
|
107
|
+
post_install_message:
|
108
108
|
rdoc_options: []
|
109
109
|
require_paths:
|
110
110
|
- lib
|
@@ -119,8 +119,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
119
119
|
- !ruby/object:Gem::Version
|
120
120
|
version: '0'
|
121
121
|
requirements: []
|
122
|
-
rubygems_version: 3.
|
123
|
-
signing_key:
|
122
|
+
rubygems_version: 3.3.16
|
123
|
+
signing_key:
|
124
124
|
specification_version: 4
|
125
125
|
summary: Sort lines in YAML files in a predictable order
|
126
126
|
test_files: []
|