class HTMLProofer::Check
Mostly handles issue management and collecting of external URLs.
Attributes
element[R]
external_urls[R]
html[R]
internal_urls[R]
issues[R]
node[R]
options[R]
path[R]
src[R]
Public Class Methods
new(src, path, html, logger, cache, options)
click to toggle source
# File lib/html-proofer/check.rb, line 8 def initialize(src, path, html, logger, cache, options) @src = src @path = path @html = remove_ignored(html) @logger = logger @cache = cache @options = options @issues = [] @internal_urls = {} @external_urls = {} end
subchecks()
click to toggle source
# File lib/html-proofer/check.rb, line 52 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, path: nil, status: -1, content: nil)
click to toggle source
# File lib/html-proofer/check.rb, line 29 def add_issue(desc, line: nil, path: nil, status: -1, content: nil) @issues << Issue.new(path || @path, desc, line: line, status: status, content: content) false end
add_to_external_urls(url)
click to toggle source
# File lib/html-proofer/check.rb, line 42 def add_to_external_urls(url) return if @external_urls[url] if @external_urls[url] @external_urls[url] << @path else @external_urls[url] = [@path] end end
add_to_internal_urls(url, internal_url)
click to toggle source
# File lib/html-proofer/check.rb, line 34 def add_to_internal_urls(url, internal_url) if @internal_urls[url] @internal_urls[url] << internal_url else @internal_urls[url] = [internal_url] end end
blank?(attr)
click to toggle source
# File lib/html-proofer/check.rb, line 64 def blank?(attr) attr.nil? || attr.empty? end
create_element(node)
click to toggle source
# File lib/html-proofer/check.rb, line 20 def create_element(node) @node = node Element.new(node, self, @logger) end
run()
click to toggle source
# File lib/html-proofer/check.rb, line 25 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 70 def remove_ignored(html) html.css('code, pre, tt').each(&:unlink) html end