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.
-
#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, status: -1,, content: nil) ⇒ Object
- #add_path_for_url(url) ⇒ Object
- #add_to_external_urls(url) ⇒ Object
- #blank?(attr) ⇒ Boolean
- #create_element(node) ⇒ Object
-
#initialize(src, path, html, options) ⇒ Check
constructor
A new instance of Check.
- #run ⇒ Object
Constructor Details
#initialize(src, path, html, options) ⇒ Check
Returns a new instance of Check.
8 9 10 11 12 13 14 15 |
# File 'lib/html-proofer/check.rb', line 8 def initialize(src, path, html, ) @src = src @path = path @html = remove_ignored(html) @options = @issues = [] @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 |
#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
44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/html-proofer/check.rb', line 44 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, status: -1,, content: nil) ⇒ Object
26 27 28 |
# File 'lib/html-proofer/check.rb', line 26 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) ⇒ Object
36 37 38 39 40 41 42 |
# File 'lib/html-proofer/check.rb', line 36 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) ⇒ Object
30 31 32 33 34 |
# File 'lib/html-proofer/check.rb', line 30 def add_to_external_urls(url) return if @external_urls[url] add_path_for_url(url) end |
#blank?(attr) ⇒ Boolean
56 57 58 |
# File 'lib/html-proofer/check.rb', line 56 def blank?(attr) attr.nil? || attr.empty? end |
#create_element(node) ⇒ Object
17 18 19 20 |
# File 'lib/html-proofer/check.rb', line 17 def create_element(node) @node = node Element.new(node, self) end |
#run ⇒ Object
22 23 24 |
# File 'lib/html-proofer/check.rb', line 22 def run raise NotImplementedError, 'HTMLProofer::Check subclasses must implement #run' end |