Class: HTMLProofer::Check
- Inherits:
-
Object
- Object
- HTMLProofer::Check
- Defined in:
- lib/html-proofer/check.rb
Overview
Mostly handles issue management and collecting of external URLs.
Direct Known Subclasses
FaviconCheck, HtmlCheck, ImageCheck, LinkCheck, OpenGraphCheck, ScriptCheck
Instance Attribute Summary collapse
-
#element ⇒ Object
readonly
Returns the value of attribute element.
-
#external_urls ⇒ Object
readonly
Returns the value of attribute external_urls.
-
#html ⇒ Object
readonly
Returns the value of attribute html.
-
#internal_urls ⇒ Object
readonly
Returns the value of attribute internal_urls.
-
#issues ⇒ Object
readonly
Returns the value of attribute issues.
-
#node ⇒ Object
readonly
Returns the value of attribute node.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#path ⇒ Object
readonly
Returns the value of attribute path.
-
#src ⇒ Object
readonly
Returns the value of attribute src.
Class Method Summary collapse
Instance Method Summary collapse
- #add_issue(desc, line: nil, path: nil, status: -1,, content: nil) ⇒ Object
- #add_to_external_urls(url) ⇒ Object
- #add_to_internal_urls(url, internal_url) ⇒ Object
- #blank?(attr) ⇒ Boolean
- #create_element(node) ⇒ Object
-
#initialize(src, path, html, logger, cache, options) ⇒ Check
constructor
A new instance of Check.
- #run ⇒ Object
Constructor Details
#initialize(src, path, html, logger, cache, options) ⇒ Check
Returns a new instance of Check.
8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/html-proofer/check.rb', line 8 def initialize(src, path, html, logger, cache, ) @src = src @path = path @html = remove_ignored(html) @logger = logger @cache = cache @options = @issues = [] @internal_urls = {} @external_urls = {} end |
Instance Attribute Details
#element ⇒ Object (readonly)
Returns the value of attribute element.
6 7 8 |
# File 'lib/html-proofer/check.rb', line 6 def element @element end |
#external_urls ⇒ Object (readonly)
Returns the value of attribute external_urls.
6 7 8 |
# File 'lib/html-proofer/check.rb', line 6 def external_urls @external_urls end |
#html ⇒ Object (readonly)
Returns the value of attribute html.
6 7 8 |
# File 'lib/html-proofer/check.rb', line 6 def html @html end |
#internal_urls ⇒ Object (readonly)
Returns the value of attribute internal_urls.
6 7 8 |
# File 'lib/html-proofer/check.rb', line 6 def internal_urls @internal_urls end |
#issues ⇒ Object (readonly)
Returns the value of attribute issues.
6 7 8 |
# File 'lib/html-proofer/check.rb', line 6 def issues @issues end |
#node ⇒ Object (readonly)
Returns the value of attribute node.
6 7 8 |
# File 'lib/html-proofer/check.rb', line 6 def node @node end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
6 7 8 |
# File 'lib/html-proofer/check.rb', line 6 def @options end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
6 7 8 |
# File 'lib/html-proofer/check.rb', line 6 def path @path end |
#src ⇒ Object (readonly)
Returns the value of attribute src.
6 7 8 |
# File 'lib/html-proofer/check.rb', line 6 def src @src end |
Class Method Details
.subchecks ⇒ Object
52 53 54 55 56 57 58 59 60 61 62 |
# 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 |
Instance Method Details
#add_issue(desc, line: nil, path: nil, status: -1,, content: nil) ⇒ Object
29 30 31 32 |
# 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) ⇒ Object
42 43 44 45 46 47 48 49 50 |
# 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) ⇒ Object
34 35 36 37 38 39 40 |
# 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) ⇒ Boolean
64 65 66 |
# File 'lib/html-proofer/check.rb', line 64 def blank?(attr) attr.nil? || attr.empty? end |
#create_element(node) ⇒ Object
20 21 22 23 |
# File 'lib/html-proofer/check.rb', line 20 def create_element(node) @node = node Element.new(node, self, @logger) end |
#run ⇒ Object
25 26 27 |
# File 'lib/html-proofer/check.rb', line 25 def run raise NotImplementedError, 'HTMLProofer::Check subclasses must implement #run' end |