yalphabetize 0.8.0 → 0.10.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/yalphabetize/file_yalphabetizer.rb +2 -2
- data/lib/yalphabetize/logger.rb +4 -4
- data/lib/yalphabetize/reader.rb +10 -1
- data/lib/yalphabetize/version.rb +1 -1
- data/lib/yalphabetize/writer.rb +5 -1
- data/lib/yalphabetize/yalphabetizer.rb +7 -7
- data/lib/yalphabetize.rb +2 -1
- metadata +21 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b2b58ea00743bea3a0a4ca4ef92caa428ced099cdf28bf4caa37bf7214333ade
|
4
|
+
data.tar.gz: b8c5d394eaf0aef402e4cab38dd1018560950e36488fb60537f9fa48c201985b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 54d23c05ae16c9eaa72b1f14a817618dbee8e116a0b24d46f08bbfc7ea009ad449e784f8ad07d24f159446deed6382bb7f403393ca45287d16ce740f3ec157b4
|
7
|
+
data.tar.gz: 731ca71c870831cd1d5b848f46a7d9e93c924d4e76304624762f7ff28c03e1d4eb4144e647ce059d3ce3315c3a48b29553d6e349f150be9777e6f2e4d41471af
|
@@ -33,11 +33,11 @@ module Yalphabetize
|
|
33
33
|
end
|
34
34
|
|
35
35
|
def offences?
|
36
|
-
offence_detector_class.new(stream_node, order_checker_class:
|
36
|
+
offence_detector_class.new(stream_node, order_checker_class:).offences?
|
37
37
|
end
|
38
38
|
|
39
39
|
def alphabetize
|
40
|
-
alphabetizer_class.new(stream_node, order_checker_class:
|
40
|
+
alphabetizer_class.new(stream_node, order_checker_class:).call
|
41
41
|
end
|
42
42
|
|
43
43
|
def handle_aliases
|
data/lib/yalphabetize/logger.rb
CHANGED
@@ -30,13 +30,13 @@ module Yalphabetize
|
|
30
30
|
output.puts send(list_offences_color, "Offences: #{offences.size}")
|
31
31
|
|
32
32
|
offences.each { |file_path, status| puts_offence(file_path, status) }
|
33
|
-
return unless
|
33
|
+
return unless uncorrected_offences?
|
34
34
|
|
35
35
|
output.puts 'Offences can be automatically fixed with `-a` or `--autocorrect`'
|
36
36
|
end
|
37
37
|
|
38
|
-
def
|
39
|
-
|
38
|
+
def uncorrected_offences?
|
39
|
+
offences.value?(:detected)
|
40
40
|
end
|
41
41
|
|
42
42
|
def log_correction(file_path)
|
@@ -58,7 +58,7 @@ module Yalphabetize
|
|
58
58
|
end
|
59
59
|
|
60
60
|
def list_offences_color
|
61
|
-
offences? ? :red : :green
|
61
|
+
offences.any? ? :red : :green
|
62
62
|
end
|
63
63
|
|
64
64
|
def red(string)
|
data/lib/yalphabetize/reader.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require 'psych'
|
4
|
+
require 'psych/comments'
|
4
5
|
|
5
6
|
module Yalphabetize
|
6
7
|
class Reader
|
@@ -21,7 +22,7 @@ module Yalphabetize
|
|
21
22
|
end
|
22
23
|
|
23
24
|
def stream_node
|
24
|
-
@_stream_node ||=
|
25
|
+
@_stream_node ||= parser_class.parse_stream file
|
25
26
|
rescue Psych::SyntaxError => e
|
26
27
|
raise Yalphabetize::ParsingError.new(
|
27
28
|
path,
|
@@ -32,5 +33,13 @@ module Yalphabetize
|
|
32
33
|
e.context
|
33
34
|
)
|
34
35
|
end
|
36
|
+
|
37
|
+
def parser_class
|
38
|
+
if Yalphabetize.config['preserve_comments']
|
39
|
+
Psych::Comments
|
40
|
+
else
|
41
|
+
Psych
|
42
|
+
end
|
43
|
+
end
|
35
44
|
end
|
36
45
|
end
|
data/lib/yalphabetize/version.rb
CHANGED
data/lib/yalphabetize/writer.rb
CHANGED
@@ -20,7 +20,11 @@ module Yalphabetize
|
|
20
20
|
attr_reader :stream_node, :path
|
21
21
|
|
22
22
|
def new_file_content
|
23
|
-
@_new_file_content ||=
|
23
|
+
@_new_file_content ||= if Yalphabetize.config['preserve_comments']
|
24
|
+
Psych::Comments.emit_yaml stream_node
|
25
|
+
else
|
26
|
+
stream_node.to_yaml(nil, line_width: MAX_LINE_WIDTH)
|
27
|
+
end
|
24
28
|
end
|
25
29
|
|
26
30
|
def indent_sequences
|
@@ -32,13 +32,13 @@ module Yalphabetize
|
|
32
32
|
def process_file(file_path)
|
33
33
|
file_yalphabetizer_class.new(
|
34
34
|
file_path,
|
35
|
-
reader_class
|
36
|
-
offence_detector_class
|
37
|
-
logger
|
35
|
+
reader_class:,
|
36
|
+
offence_detector_class:,
|
37
|
+
logger:,
|
38
38
|
autocorrect: options[:autocorrect],
|
39
|
-
alphabetizer_class
|
40
|
-
writer_class
|
41
|
-
order_checker_class:
|
39
|
+
alphabetizer_class:,
|
40
|
+
writer_class:,
|
41
|
+
order_checker_class:
|
42
42
|
).call
|
43
43
|
end
|
44
44
|
|
@@ -56,7 +56,7 @@ module Yalphabetize
|
|
56
56
|
|
57
57
|
def final_log
|
58
58
|
logger.final_summary
|
59
|
-
logger.
|
59
|
+
logger.uncorrected_offences? ? 1 : 0
|
60
60
|
end
|
61
61
|
|
62
62
|
def reader_class
|
data/lib/yalphabetize.rb
CHANGED
metadata
CHANGED
@@ -1,15 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: yalphabetize
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.10.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sam Jenkins
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
12
|
-
dependencies:
|
11
|
+
date: 2024-11-23 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: psych-comments
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
13
27
|
description:
|
14
28
|
email:
|
15
29
|
executables:
|
@@ -44,7 +58,9 @@ homepage:
|
|
44
58
|
licenses: []
|
45
59
|
metadata:
|
46
60
|
rubygems_mfa_required: 'true'
|
47
|
-
post_install_message:
|
61
|
+
post_install_message: |
|
62
|
+
yalphabetize 0.10.0 now supports YAML comments!
|
63
|
+
For more info: https://github.com/samrjenkins/yalphabetize?tab=readme-ov-file#preserve_comments
|
48
64
|
rdoc_options: []
|
49
65
|
require_paths:
|
50
66
|
- lib
|
@@ -59,7 +75,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
59
75
|
- !ruby/object:Gem::Version
|
60
76
|
version: '0'
|
61
77
|
requirements: []
|
62
|
-
rubygems_version: 3.
|
78
|
+
rubygems_version: 3.3.27
|
63
79
|
signing_key:
|
64
80
|
specification_version: 4
|
65
81
|
summary: Alphabetize your YAML files
|