Class: HTML::Proofer::CheckRunner

Inherits:
Object
  • Object
show all
Defined in:
lib/html/proofer/check_runner.rb,
lib/html/proofer/check_runner/issue.rb

Overview

Mostly handles issue management and collecting of external URLs.

Direct Known Subclasses

FaviconCheck, HtmlCheck, ImageCheck, LinkCheck, ScriptCheck

Defined Under Namespace

Classes: Issue, SortedIssues

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(src, path, html, opts = {}) ⇒ CheckRunner

Returns a new instance of CheckRunner.


10
11
12
13
14
15
16
17
18
19
# File 'lib/html/proofer/check_runner.rb', line 10

def initialize(src, path, html, opts={})
  @src    = src
  @path   = path
  @html   = remove_ignored(html)
  @options = opts
  @issues = []
  @href_ignores = @options[:href_ignore]
  @alt_ignores = @options[:alt_ignore]
  @external_urls = {}
end

Instance Attribute Details

#alt_ignoresObject (readonly)

Returns the value of attribute alt_ignores


8
9
10
# File 'lib/html/proofer/check_runner.rb', line 8

def alt_ignores
  @alt_ignores
end

#external_urlsObject (readonly)

Returns the value of attribute external_urls


8
9
10
# File 'lib/html/proofer/check_runner.rb', line 8

def external_urls
  @external_urls
end

#href_ignoresObject (readonly)

Returns the value of attribute href_ignores


8
9
10
# File 'lib/html/proofer/check_runner.rb', line 8

def href_ignores
  @href_ignores
end

#issuesObject (readonly)

Returns the value of attribute issues


8
9
10
# File 'lib/html/proofer/check_runner.rb', line 8

def issues
  @issues
end

#optionsObject (readonly)

Returns the value of attribute options


8
9
10
# File 'lib/html/proofer/check_runner.rb', line 8

def options
  @options
end

#pathObject (readonly)

Returns the value of attribute path


8
9
10
# File 'lib/html/proofer/check_runner.rb', line 8

def path
  @path
end

#srcObject (readonly)

Returns the value of attribute src


8
9
10
# File 'lib/html/proofer/check_runner.rb', line 8

def src
  @src
end

Class Method Details

.checksObject


37
38
39
40
41
42
43
44
45
46
# File 'lib/html/proofer/check_runner.rb', line 37

def self.checks
  classes = []

  ObjectSpace.each_object(Class) do |c|
    next unless c.superclass == self
    classes << c
  end

  classes
end

Instance Method Details

#add_issue(desc, line_number = nil, status = -1)) ⇒ Object


25
26
27
# File 'lib/html/proofer/check_runner.rb', line 25

def add_issue(desc, line_number = nil, status = -1)
  @issues << Issue.new(@path, desc, line_number, status)
end

#add_to_external_urls(href) ⇒ Object


29
30
31
32
33
34
35
# File 'lib/html/proofer/check_runner.rb', line 29

def add_to_external_urls(href)
  if @external_urls[href]
    @external_urls[href] << @path
  else
    @external_urls[href] = [@path]
  end
end

#runObject


21
22
23
# File 'lib/html/proofer/check_runner.rb', line 21

def run
  fail NotImplementedError, 'HTML::Proofer::CheckRunner subclasses must implement #run'
end