-
-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathvalidate_configs
More file actions
executable file
·44 lines (38 loc) · 1.01 KB
/
validate_configs
File metadata and controls
executable file
·44 lines (38 loc) · 1.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#!/usr/bin/env ruby
# frozen_string_literal: true
require 'bundler/setup'
require 'html2rss'
unless Html2rss::Config.respond_to?(:validate_yaml)
warn 'Error: installed html2rss gem does not support Config.validate_yaml.'
warn 'Run: bundle update html2rss'
exit 1
end
files = Dir['lib/html2rss/configs/**/*.yml']
failed = []
files.each do |file|
result = Html2rss::Config.validate_yaml(file)
if result.success?
puts "ok #{file}"
else
puts "FAIL #{file}"
result.errors.to_h.each do |key, messages|
Array(messages).each { |msg| warn " #{key}: #{msg}" }
end
failed << file
end
rescue Psych::Exception => error
puts "FAIL #{file}"
warn " parse: #{error.message}"
failed << file
rescue StandardError => error
puts "FAIL #{file}"
warn " validation: #{error.class}: #{error.message}"
failed << file
end
puts
if failed.empty?
puts "#{files.size} configs validated successfully."
else
warn "#{failed.size}/#{files.size} configs failed validation."
exit 1
end