Class: Epic::Validator::HTML

Inherits:
Base
  • Object
show all
Defined in:
lib/epic/validator/html.rb

Instance Attribute Summary

Attributes inherited from Base

#errors, #path

Instance Method Summary collapse

Methods inherited from Base

#initialize

Methods included from Errors

#display_errors, #errors, #valid?

Methods inherited from Base

#base_path, #configuration, configuration, configure, #display_path, #tmp_path

Constructor Details

This class inherits a constructor from Epic::Validator::Base

Instance Method Details

#doctypeObject



8
9
10
# File 'lib/epic/validator/html.rb', line 8

def doctype
  configuration.doctype || "HTML 4.01 Transitional"
end

#validate(filename = nil) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/epic/validator/html.rb', line 12

def validate(filename=nil)
  @path = filename || path
  $stdout.print "   #{display_path}  validating . . . "
  
  validator.set_doctype!(doctype)

  results = validator.validate_file(path)
  
  @errors = results.errors
  
  if valid?
    $stdout.puts "OK"
  else
    $stdout.puts "validation errors"
    display_errors
  end
  
  valid?
end

#validatorObject



4
5
6
# File 'lib/epic/validator/html.rb', line 4

def validator
  @validator ||= W3CValidators::MarkupValidator.new
end