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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 439903dec6d44955a80683c7d82fecf2179f22e3
4
- data.tar.gz: bb367add8693d7759fff4f9e2698003859ba6faa
3
+ metadata.gz: 2ed8e87937af1ed8f601b81c9fa4383f4f0fa45e
4
+ data.tar.gz: a43566eda64515f35c83a873c9d401697c4f1d0f
5
5
  SHA512:
6
- metadata.gz: 61dd81c4a7b4813ebaf0e31ba17219d52f1af5382c28bcc554d4bae1471b546540eab68c4c93acd56d0c579f73080c6babe148545d466a038208efad5d230279
7
- data.tar.gz: 20971c7dc266474f42a69553b5f58dc95480643c91802a2435b90d76b532770b70f01c20d9d86ec2efde7dff11042eb2100c5ea6a0b641227a0012f6f3a20434
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 input.eql?(norm)
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
@@ -2,5 +2,5 @@
2
2
 
3
3
  module YamlNormalizer
4
4
  # The current Yaml Normalizer version
5
- VERSION = '0.2.1'
5
+ VERSION = '0.2.2'
6
6
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: yaml_normalizer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Wolfgang Teuber