class HTMLProofer::Check
Mostly handles issue management and collecting of external URLs.
Attributes
element[R]
external_urls[R]
html[R]
issues[R]
node[R]
options[R]
path[R]
src[R]
Public Class Methods
new(src, path, html, logger, options)
click to toggle source
# File lib/html-proofer/check.rb, line 8 def initialize(src, path, html, logger, options) @src = src @path = path @html = remove_ignored(html) @logger = logger @options = options @issues = [] @external_urls = {} end
subchecks()
click to toggle source
# File lib/html-proofer/check.rb, line 45 def self.subchecks classes = [] ObjectSpace.each_object(Class) do |c| next unless c.superclass == self classes << c end classes end
Public Instance Methods
add_issue(desc, line: nil, status: -1, content: nil)
click to toggle source
# File lib/html-proofer/check.rb, line 27 def add_issue(desc, line: nil, status: -1, content: nil) @issues << Issue.new(@path, desc, line: line, status: status, content: content) end
add_path_for_url(url)
click to toggle source
# File lib/html-proofer/check.rb, line 37 def add_path_for_url(url) if @external_urls[url] @external_urls[url] << @path else @external_urls[url] = [@path] end end
add_to_external_urls(url)
click to toggle source
# File lib/html-proofer/check.rb, line 31 def add_to_external_urls(url) return if @external_urls[url] add_path_for_url(url) end
blank?(attr)
click to toggle source
# File lib/html-proofer/check.rb, line 57 def blank?(attr) attr.nil? || attr.empty? end
create_element(node)
click to toggle source
# File lib/html-proofer/check.rb, line 18 def create_element(node) @node = node Element.new(node, self, @logger) end
run()
click to toggle source
# File lib/html-proofer/check.rb, line 23 def run raise NotImplementedError, 'HTMLProofer::Check subclasses must implement #run' end
Private Instance Methods
remove_ignored(html)
click to toggle source
# File lib/html-proofer/check.rb, line 63 def remove_ignored(html) html.css('code, pre, tt').each(&:unlink) html end