Class: Images
- Inherits:
-
HTML::Proofer::Checks::Check
- Object
- HTML::Proofer::Checks::Check
- Images
- Defined in:
- lib/html/proofer/checks/images.rb
Instance Attribute Summary
Attributes inherited from HTML::Proofer::Checks::Check
#additional_href_ignores, #hydra, #issues, #options, #path, #src
Instance Method Summary collapse
Methods inherited from HTML::Proofer::Checks::Check
#add_issue, #initialize, #output_filenames, #request_url, subclasses, #validate_url
Constructor Details
This class inherits a constructor from HTML::Proofer::Checks::Check
Instance Method Details
#run ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/html/proofer/checks/images.rb', line 26 def run @html.css('img').each do |img| img = Image.new img, self # screenshot filenames, return because invalid URL return self.add_issue "image has a terrible filename (#{img.src})" if img.terrible_filename? # does the image exist? if img.missing_src? self.add_issue "image has no src attribute" elsif img.remote? validate_url img.src, "external image #{img.src} does not exist" else self.add_issue("internal image #{img.src} does not exist") unless img.exists? end # check alt tag self.add_issue "image #{img.src} does not have an alt attribute" unless img.valid_alt_tag? end end |