Class: ScriptCheck
- Inherits:
-
HTMLProofer::Check
- Object
- HTMLProofer::Check
- ScriptCheck
- Defined in:
- lib/html-proofer/check/scripts.rb
Instance Attribute Summary collapse
-
#src ⇒ Object
readonly
Returns the value of attribute src.
Attributes inherited from HTMLProofer::Check
#element, #external_urls, #html, #issues, #node, #options, #path
Instance Method Summary collapse
Methods inherited from HTMLProofer::Check
#add_issue, #add_path_for_url, #add_to_external_urls, #blank?, #create_element, #initialize, subchecks
Constructor Details
This class inherits a constructor from HTMLProofer::Check
Instance Attribute Details
#src ⇒ Object (readonly)
Returns the value of attribute src.
2 3 4 |
# File 'lib/html-proofer/check/scripts.rb', line 2 def src @src end |
Instance Method Details
#missing_src? ⇒ Boolean
4 5 6 |
# File 'lib/html-proofer/check/scripts.rb', line 4 def missing_src? !@script.src end |
#run ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/html-proofer/check/scripts.rb', line 8 def run @html.css('script').each do |node| @script = create_element(node) line = node.line content = node.content next if @script.ignore? next unless node.text.strip.empty? # does the script exist? if missing_src? add_issue('script is empty and has no src attribute', line: line, content: content) elsif @script.remote? add_to_external_urls(@script.src) elsif !@script.exists? add_issue("internal script #{@script.src} does not exist", line: line, content: content) end end external_urls end |