Permalink
Browse files

Merge branch 'validate_dots'

  • Loading branch information...
2 parents 6f5fb13 + 6d222cb commit 484b872972c7723fb7f1aa265d7d31ad977289a0 @jaimeiniesta jaimeiniesta committed Jun 18, 2010
Showing with 29 additions and 6 deletions.
  1. +29 −6 railties/guides/w3c_validator.rb
@@ -35,18 +35,21 @@ class Validator
def validate
validator = MarkupValidator.new
+ STDOUT.sync = true
+ errors_on_guides = {}
guides_to_validate.each do |f|
- puts "Validating #{f}"
results = validator.validate_file(f)
- if !results.validity
- puts "#{f} FAILED W3C validation with #{results.errors.size} error(s):"
- results.errors.each do |error|
- puts error.to_s
- end
+ if results.validity
+ print "."
+ else
+ print "E"
+ errors_on_guides[f] = results.errors
end
end
+
+ show_results(errors_on_guides)
end
private
@@ -61,6 +64,26 @@ def select_only(guides)
prefixes.any? {|p| guide.start_with?("./guides/output/#{p}")}
end
end
+
+ def show_results(error_list)
+ if error_list.size == 0
+ puts "\n\nAll checked guides validate OK!"
+ else
+ error_summary = error_detail = ""
+
+ error_list.each_pair do |name, errors|
+ error_summary += "\n #{name}"
+ error_detail += "\n\n #{name} has #{errors.size} validation error(s):\n"
+ errors.each do |error|
+ error_detail += "\n "+error.to_s.gsub("\n", "")
+ end
+ end
+
+ puts "\n\nThere are #{error_list.size} guides with validation errors:\n" + error_summary
+ puts "\nHere are the detailed errors for each guide:" + error_detail
+ end
+ end
+
end
end

0 comments on commit 484b872

Please sign in to comment.