yaml-sort 2.1.1 → 2.2.0
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/.simplecov +7 -0
- data/CHANGELOG.md +16 -0
- data/Gemfile +1 -0
- data/README.md +4 -0
- data/Rakefile +1 -1
- data/lib/yaml/sort/alias.rb +39 -0
- data/lib/yaml/sort/dictionary.rb +3 -4
- data/lib/yaml/sort/parser.rb +1 -1
- data/lib/yaml/sort/version.rb +1 -1
- data/lib/yaml/sort.rb +1 -0
- metadata +5 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6c27eb85cd2257c1d9ae801f0de2bcf360f4980e40479599745ecea41f4aa1f0
|
4
|
+
data.tar.gz: 05a1eb6551c2c671ca4e1ff01ce6acd91f3954fd7eeb8b70238bb48df45c1365
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 28b1e39e69330c1d4f4f68884fb84a8ba8dcc5411315a4b37e51391a4f32b1495fbb2f90eeaa78fea283e1c1ed06f0d030f35c9642de578e4e2665d76546a8ed
|
7
|
+
data.tar.gz: '0218e2f44f0a27dc1d5ca720493be401f2e9e55276b4de733ca37f716e9b92cc1c963a0c716c34f219fe3efc6704e21df570564f356394253bc790ecc7c9644f'
|
data/.simplecov
ADDED
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.0](https://github.com/smortex/yaml-sort/tree/v2.2.0) (2022-09-27)
|
7
|
+
|
8
|
+
[Full Changelog](https://github.com/smortex/yaml-sort/compare/v2.1.1...v2.2.0)
|
9
|
+
|
10
|
+
**Implemented enhancements:**
|
11
|
+
|
12
|
+
- Add support for &anchor / \*alias [\#17](https://github.com/smortex/yaml-sort/pull/17) ([smortex](https://github.com/smortex))
|
13
|
+
|
14
|
+
**Fixed bugs:**
|
15
|
+
|
16
|
+
- Fix relocation of comments following UNINDENT [\#18](https://github.com/smortex/yaml-sort/pull/18) ([smortex](https://github.com/smortex))
|
17
|
+
|
18
|
+
**Merged pull requests:**
|
19
|
+
|
20
|
+
- Add CodeClimate integration [\#15](https://github.com/smortex/yaml-sort/pull/15) ([smortex](https://github.com/smortex))
|
21
|
+
|
6
22
|
## [v2.1.1](https://github.com/smortex/yaml-sort/tree/v2.1.1) (2022-07-03)
|
7
23
|
|
8
24
|
[Full Changelog](https://github.com/smortex/yaml-sort/compare/v2.1.0...v2.1.1)
|
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -1,5 +1,9 @@
|
|
1
1
|
# yaml-sort
|
2
2
|
|
3
|
+
[](https://github.com/smortex/yaml-sort/actions/workflows/ci.yaml)
|
4
|
+
[](https://codeclimate.com/github/smortex/yaml-sort/maintainability)
|
5
|
+
[](https://codeclimate.com/github/smortex/yaml-sort/test_coverage)
|
6
|
+
|
3
7
|
An utility to manage YAML files and ensure their lines is in a predictable order.
|
4
8
|
|
5
9
|
This is mainly indended to manage [Hiera files](https://puppet.com/docs/puppet/7/hiera_intro.html) for [Puppet](https://puppet.com/) and translation files in [Ruby on Rails](https://rubyonrails.org/) applications.
|
data/Rakefile
CHANGED
@@ -13,7 +13,7 @@ require "cucumber/rake/task"
|
|
13
13
|
|
14
14
|
Cucumber::Rake::Task.new
|
15
15
|
|
16
|
-
task default: %i[
|
16
|
+
task default: %i[spec cucumber]
|
17
17
|
|
18
18
|
file "lib/yaml/sort/parser.rb": ["lib/yaml/sort/parser.ra"] do
|
19
19
|
sh "racc --output-status --output-file=lib/yaml/sort/parser.rb lib/yaml/sort/parser.ra"
|
@@ -0,0 +1,39 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Yaml
|
4
|
+
module Sort
|
5
|
+
class Alias < Value
|
6
|
+
attr_reader :name
|
7
|
+
|
8
|
+
def initialize(anchors, name)
|
9
|
+
super()
|
10
|
+
@anchors = anchors
|
11
|
+
@name = name[:value]
|
12
|
+
end
|
13
|
+
|
14
|
+
def value?
|
15
|
+
@anchors[@name]
|
16
|
+
end
|
17
|
+
|
18
|
+
def delete_value
|
19
|
+
@anchors.delete(@name)
|
20
|
+
end
|
21
|
+
|
22
|
+
def to_s(*)
|
23
|
+
if (s = @anchors.delete(@name))
|
24
|
+
separator = case s
|
25
|
+
when List, Dictionary then "\n"
|
26
|
+
else " "
|
27
|
+
end
|
28
|
+
"&#{name}#{separator}#{s}"
|
29
|
+
else
|
30
|
+
"*#{name}"
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
def <=>(_other)
|
35
|
+
0
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
data/lib/yaml/sort/dictionary.rb
CHANGED
@@ -25,10 +25,9 @@ module Yaml
|
|
25
25
|
super + items.map do |k, v|
|
26
26
|
n += 1
|
27
27
|
case v
|
28
|
-
when List, Dictionary
|
29
|
-
|
30
|
-
|
31
|
-
"#{k.to_s(skip_first_indent: skip_first_indent && n.zero?)} #{v}"
|
28
|
+
when List, Dictionary then "#{k.to_s(skip_first_indent: skip_first_indent && n.zero?)}\n#{v}"
|
29
|
+
when Scalar, Alias then "#{k.to_s(skip_first_indent: skip_first_indent && n.zero?)} #{v}"
|
30
|
+
else raise "Unexpected type"
|
32
31
|
end
|
33
32
|
end.join("\n")
|
34
33
|
end
|
data/lib/yaml/sort/parser.rb
CHANGED
data/lib/yaml/sort/version.rb
CHANGED
data/lib/yaml/sort.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.2.0
|
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-
|
11
|
+
date: 2022-09-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: cri
|
@@ -76,6 +76,7 @@ extra_rdoc_files: []
|
|
76
76
|
files:
|
77
77
|
- ".rspec"
|
78
78
|
- ".rubocop.yml"
|
79
|
+
- ".simplecov"
|
79
80
|
- CHANGELOG.md
|
80
81
|
- CODE_OF_CONDUCT.md
|
81
82
|
- Gemfile
|
@@ -84,6 +85,7 @@ files:
|
|
84
85
|
- Rakefile
|
85
86
|
- exe/yaml-sort
|
86
87
|
- lib/yaml/sort.rb
|
88
|
+
- lib/yaml/sort/alias.rb
|
87
89
|
- lib/yaml/sort/cli.rb
|
88
90
|
- lib/yaml/sort/dictionary.rb
|
89
91
|
- lib/yaml/sort/item.rb
|
@@ -119,7 +121,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
119
121
|
- !ruby/object:Gem::Version
|
120
122
|
version: '0'
|
121
123
|
requirements: []
|
122
|
-
rubygems_version: 3.3.
|
124
|
+
rubygems_version: 3.3.22
|
123
125
|
signing_key:
|
124
126
|
specification_version: 4
|
125
127
|
summary: Sort lines in YAML files in a predictable order
|