yaml_normalizer 0.2.1 → 0.2.2
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/lib/yaml_normalizer/rake_task.rb +7 -1
- data/lib/yaml_normalizer/services/check.rb +10 -2
- data/lib/yaml_normalizer/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2ed8e87937af1ed8f601b81c9fa4383f4f0fa45e
|
4
|
+
data.tar.gz: a43566eda64515f35c83a873c9d401697c4f1d0f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 78f8a348e94be5e4c248a2f4a4702888721b104388be9c73c1a8f7a2447f08e9aa873b2192f8fa170f566fb942502c3d9dad028d3b002138c35599d15f8fe5ae
|
7
|
+
data.tar.gz: 31cb9153735178b8e40e3629707ae5d9bd721e2b86234801213bc26808b163226af5e795221549677d62d5f90d253ce6ad7efd14240e913ac15da9105780e5b4
|
@@ -40,7 +40,7 @@ module YamlNormalizer
|
|
40
40
|
yield(self) if block
|
41
41
|
|
42
42
|
desc 'Check if configured YAML are normalized'
|
43
|
-
task("#{name}:check") { check }
|
43
|
+
task("#{name}:check") { abort(check_failed(name)) unless check }
|
44
44
|
|
45
45
|
desc 'Normalize configured YAML files'
|
46
46
|
task("#{name}:normalize") { normalize }
|
@@ -48,6 +48,12 @@ module YamlNormalizer
|
|
48
48
|
|
49
49
|
private
|
50
50
|
|
51
|
+
# Error message to be printed if check fails
|
52
|
+
def check_failed(name)
|
53
|
+
"#{name}:check failed.\n" \
|
54
|
+
"Run 'rake #{name}:normalize' to normalize YAML files.\n"
|
55
|
+
end
|
56
|
+
|
51
57
|
# Checks if configured YAML are normalized
|
52
58
|
def check
|
53
59
|
Services::Check.call(*files)
|
@@ -26,13 +26,18 @@ module YamlNormalizer
|
|
26
26
|
|
27
27
|
# Normalizes all YAML files defined on instantiation.
|
28
28
|
def call
|
29
|
+
normalized = []
|
30
|
+
|
29
31
|
files.peach do |file|
|
30
32
|
if IsYaml.call(file)
|
31
|
-
normalized?(file)
|
33
|
+
normalized << normalized?(file)
|
32
34
|
else
|
35
|
+
normalized << nil
|
33
36
|
$stderr.puts "#{file} not a YAML file"
|
34
37
|
end
|
35
38
|
end
|
39
|
+
|
40
|
+
normalized.all?
|
36
41
|
end
|
37
42
|
|
38
43
|
private
|
@@ -41,12 +46,15 @@ module YamlNormalizer
|
|
41
46
|
file = Pathname.new(file).relative_path_from(Pathname.new(Dir.pwd))
|
42
47
|
input = File.read(file, mode: 'r:bom|utf-8')
|
43
48
|
norm = normalize_yaml(input)
|
49
|
+
check = input.eql?(norm)
|
44
50
|
|
45
|
-
if
|
51
|
+
if check
|
46
52
|
$stdout.puts "[PASSED] already normalized #{file}"
|
47
53
|
else
|
48
54
|
$stdout.puts "[FAILED] normalization suggested for #{file}"
|
49
55
|
end
|
56
|
+
|
57
|
+
check
|
50
58
|
end
|
51
59
|
end
|
52
60
|
end
|