Class: Canvas::ValidHtmlCheck

Inherits:
Check
  • Object
show all
Defined in:
lib/canvas/checks/valid_html_check.rb

Overview

:documented:

Instance Attribute Summary

Attributes inherited from Check

#offenses

Instance Method Summary collapse

Methods inherited from Check

#failed?, #initialize

Constructor Details

This class inherits a constructor from Canvas::Check

Instance Method Details

#html_filesObject



21
22
23
# File 'lib/canvas/checks/valid_html_check.rb', line 21

def html_files
  Dir.glob("**/*.{html,liquid}")
end

#runObject



6
7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/canvas/checks/valid_html_check.rb', line 6

def run
  html_files.each do |filename|
    file = File.read(filename)
    validator = Validator::Html.new(file)

    next if validator.validate

    validator.errors.map(&:message).each do |message|
      @offenses << Offense.new(
        message: "Invalid HTML: #{filename} - \n#{message}"
      )
    end
  end
end