Class: Nanoc3::Extra::Validators::W3C
- Inherits:
-
Object
- Object
- Nanoc3::Extra::Validators::W3C
- Defined in:
- lib/nanoc3/extra/validators/w3c.rb
Overview
A validator that uses the W3C web service to validate HTML and CSS files.
Instance Method Summary collapse
-
#initialize(dir, types) ⇒ W3C
constructor
A new instance of W3C.
-
#run ⇒ void
Starts the validator.
Constructor Details
#initialize(dir, types) ⇒ W3C
Returns a new instance of W3C.
13 14 15 16 |
# File 'lib/nanoc3/extra/validators/w3c.rb', line 13 def initialize(dir, types) @dir = dir @types = types end |
Instance Method Details
#run ⇒ void
This method returns an undefined value.
Starts the validator. The results will be printed to stdout.
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/nanoc3/extra/validators/w3c.rb', line 21 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 |