Class: Scripts

Inherits:
HTML::Proofer::Checks::Check show all
Defined in:
lib/html/proofer/checks/scripts.rb

Instance Attribute Summary

Attributes inherited from HTML::Proofer::Checks::Check

#additional_alt_ignores, #additional_href_ignores, #external_urls, #issues, #options, #path, #src

Instance Method Summary collapse

Methods inherited from HTML::Proofer::Checks::Check

#add_issue, #add_to_external_urls, #initialize, #output_filenames, subclasses

Constructor Details

This class inherits a constructor from HTML::Proofer::Checks::Check

Instance Method Details

#runObject



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/html/proofer/checks/scripts.rb', line 20

def run
  @html.css("script").each do |s|
    script = Script.new s, "script", self

    next if script.ignore?
    next unless script.blank?

    # does the script exist?
    if script.missing_src?
      self.add_issue "script is empty and has no src attribute"
    elsif script.remote?
      add_to_external_urls script.src
    else
      self.add_issue("internal script #{script.src} does not exist") unless script.exists?
    end

  end

  external_urls
end