Class: Epic::Validator::HTML

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

Instance Method Summary collapse

Methods inherited from Base

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

Instance Method Details

#validate(path) ⇒ Object



50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
# File 'lib/epic.rb', line 50

def validate(path)
  $stdout.print "   #{path}  validating . . . "
  
  doctype = configuration.doctype || "HTML 4.01 Transitional"
  validator.set_doctype!(doctype)

  results = validator.validate_file(path)
  
  valid = results.errors.length <= 0
  
  if valid
    $stdout.puts "OK"
  else
    $stdout.puts "validation errors"
    results.errors.each do |err|
      $stdout.puts
      $stdout.puts err.to_s
    end
  end
  
  valid
end

#validatorObject



46
47
48
# File 'lib/epic.rb', line 46

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