A validator that uses the W3C web service to validate HTML and CSS files.
@param [String] dir The directory that will be searched for HTML and/or CSS files to validate
@param [Array<Symbol>] types A list of types to check. Allowed types are `:html` and `:css`.
# File lib/nanoc3/extra/validators/w3c.rb, line 12 def initialize(dir, types) @dir = dir @types = types end
Starts the validator. The results will be printed to stdout.
@return [void]
# File lib/nanoc3/extra/validators/w3c.rb, line 20 def run # Load validator require 'w3c_validators' # Find all files filenames = [] extensions = types_to_extensions(@types) extensions.each { |extension| filenames.concat(Dir[@dir + '/**/*.' + extension]) } # Validate each file filenames.each do |filename| validation_started(filename) extension = File.extname(filename)[1..-1] results = validator_for(extension).validate_file(filename) validation_ended(filename, results.errors) end end
Generated with the Darkfish Rdoc Generator 2.