Validate and enforce style via CI

This commit is contained in:
Ben Balter
2018-04-09 19:50:37 -04:00
parent 678ff1f164
commit 39a52d72a2
4 changed files with 40 additions and 0 deletions

27
script/validate-html Executable file
View File

@@ -0,0 +1,27 @@
#!/usr/bin/env ruby
require 'w3c_validators'
def validator(file)
extension = File.extname(file)
if extension == '.html'
W3CValidators::NuValidator.new
elsif extension == '.css'
W3CValidators::CSSValidator.new
end
end
def validate(file)
puts "Checking #{file}..."
path = File.expand_path "../_site/#{file}", __dir__
results = validator(file).validate_file(path)
return puts 'Valid!' if results.errors.empty?
results.errors.each { |err| puts err.to_s }
exit 1
end
validate 'index.html'
validate File.join 'assets', 'css', 'style.css'